How to send gmail email with asp.net - c#? - asp.net

hi i want to send a some form entries resulting in a postback to be mailed automatically with my gmail account to the target mail id entered by the user with asp.net - c#?

You can send an email using: http://www.systemnetmail.com/
Gmail uses the mail server that you can configure (I forget the exact address, but you can find it on the google site) your web application to use when it sends mail.

As gmail lets you send mail var SMTP you should just be able to use the SmtpClient class in the .net framework.
Do you however often have to configure your virus scanner to allow out going emails from the process the Asp.net is running in.

Related

Send mail via SendGrid to Outlook was always failing

I am a newbie in using SendGrid. I have a web application that send a mail to users after the successful registration. I am using send grid to send mails.
It works fine when I try to send Google email accounts. But when I send mails to Outlook email addresses, it always failed to deliver emails.
I checked the SendGrid 'Activity' section it shows like below.
You might need to setup domain authentication. This link should be a good place to start: https://sendgrid.com/docs/ui/account-and-settings/how-to-set-up-domain-authentication/
Outlook might have different firewall rules blocking incoming (potentially malicious) emails while GMail might have a different set of them.

How to send mail from non existing mail mailsender spring?

How to send a mail from non existing mail? Example: no-reply#mydomain.com using Spring Mail Sender Configuration. A mail doesn't exists so that reply to email address should fail.
Solution with java mail also preferred.
I tried with this too. It is not working with spring framework.
(Unknown Sender) when sending email with pdf attachment created in iText from java application
no-reply#mydomain.com
If you're not using SMTP authentication then it doesn't matter whether the email exists or not.
You can send email from addresses that doesn't exist without using SMTP authentication but that's usually a bad practice because such email's are usually evaluated as spam by most of the spam filters.
See this answer for more details.
Hence it's best practice to send email using SMTP authentication. But when sending email using that way you should have all credentials like email, password, outgoing server, port etc... and so you'll need a email that does exists.

Email sending in asp.net without authentication

I want to send email in asp.net web application without authentication, that means without having to enter the password by the email sender just like in contact page of a normal website. Any help on this will be highly appreciated. Thanks in advance.
If your e-mail provider, like gmail, demands authentication, you cannot "send email without authentication".
Each and every contact form you will find on the Internet for sure will do some backend stuff for sending emails, including authentication against the SMTP.
Create an account for that purpose, and use those credentials.

Can asp.net membership controls (PasswordRecovery, CreateUserWizard) be configured to work without SMTP Server?

Our IT staff wants to remove SMTP access from the website layer and have all emails from the website be sent by making a web service call to an internal service which will then send the email directly through an Exchange server.
Is there a way to configure the PasswordRecovery and CreateUserWizard controls to let me send the email directly (by calling the service) instead of having it send automatically using the configured SMTP settings in the web.config?
I don't want to rewrite the pages and use the API directly if I can just configure the controls to work as they are. Otherwise I think I'll have to take out the PasswordRecovery and CreateUserWizard and replace them with my own controls that call into the Membership API.
I found out that CreateUserWizard has an event, OnSendingMail, which can be subscribed to. Setting the MailMessageEventArgs e.Cancel = true causes the email to not be sent by the control but does not cancel the workflow of the wizard. So I cancel the email and send it here without having to rewrite anything.
PasswordRecovery I had to end up rewriting. Just used the membership API to get the MembershipUser, call ResetPassword(), and send the email with the new password directly.

web.config email query

In my web.config file there are below entries. It seems like it is used to send mails from my website.
How i know maiks has been sent from my website?
<add key="emailFromAddress" value="help-desk#home.com"/>
<add key="emailTo_StoreAuthorise" value="help-desk#home.com"/>
You can't know that mails have been sent from your web application. It is the responsibility of the mail server to process emails, not the web server - this means that your code will use mail code, which uses the mail server (e.g. exchange) to actually send out the mails.
What you could do, is check the mail server to see what's been sent out on this email address. It's not perfect, because you may have a user who sends mails on this account, so it will only tell you that mail was sent - not that this mail was sent by your code.
If you need this functionality, you'll need to write this information out at some point - e.g. when the code requests the send mail.
The mails are not sent through your website, but through your mail server.
Your options are:
Check the mail server to see if it logs your sent mails.
Add code to the method that sends the mail in your website to log this event in some place.
Maybe check some kind of IIS-log.
Use such a code to generate link wich will set the mail's subject:
<asp:HyperLink id="EMailLink" runat="server"
NavigateUrl="mailto:<%# System.Configuration.ConfigurationSettings.AppSettings("emailFromAddress") %>?subject=[YourSite.com]"
>EmailUs</asp:HyperLink>
I'm assuming you didn't write the app and have inherited it from someone else, but now wish to check that the email functionality is working and can't be bothered to look at the code?
If you are just trying to check that they work in a development setting and your app has a mailSettings config element, you could configure it so that the mails are written to disk, as shown here.

Resources