0
votes

I've been trying unsuccessfully to get an email in my Azure Website. I can get it working on my localhost using either the GMail SMTP settings. However when deployed to my windows azure website ,even on my localhost IIS it doesn't work. none mail being sent or received!!! there is my code in web.config:

<appSettings>
        <add key="webpages:Version" value="3.0.0.0" />
        <add key="webpages:Enabled" value="false" />
        <add key="ClientValidationEnabled" value="true" />
        <add key="UnobtrusiveJavaScriptEnabled" value="true" />
        <add key="Smtp_Server" value="smtp.gmail.com" />
        <add key="Smtp_Port" value="587" />
        <add key="Smtp_UserName" value="*****" />
        <add key="Smtp_Password" value="***" />
        <add key="Smtp_bSSLConnection" value="True" />
        <add key="ActiveSendMail" value="False" />
        <add key="SecurityKey" value="****" />
      </appSettings>

When i was searching i found a link that told me that "SMTP is not supported by Azure : http://www.postseek.com/meta/488719217d716a4fc35c7d6f336e263c" I want to know is that correct?? Would i use another sent mail server?

3

3 Answers

1
votes

SMTP probably isn't supported.

You could us Mandrill they have an api that you can use to send email that works over http, so you don't need to worry about smtp.

0
votes

Even though I logged in to my Gmail account and "white listed" my C# code hosted in Azure, Gmail kept on blocking my emails.

I opted instead to use Hotmail SMTP and use that account instead of Gmail SMTP.

ASP.NET 5 example:

public class AuthMessageSender : IEmailSender, ISmsSender <br/>
{ <br/>
    public Task SendEmailAsync(string email, string subject, string message) <br/>
    { <br/>
        var mailMessage = new MailMessage(email, email, subject, message); <br/>
        var builder = new ConfigurationBuilder(); <br/>
        var config = builder.Build(); <br/>
        var client = new SmtpClient("smtp.live.com", 587) <br/>
        { <br/>
            Credentials = new NetworkCredential("[email protected]", "password"),
            EnableSsl = true <br/>
        };<br/>
        client.Send(email, "[email protected]", subject, message); <br/>
        return Task.FromResult(0); <br/>
    } <br/>
}
0
votes
  1. Go to your Gmail account. Allow less secure app to access third party
  2. When allow less secure app the email will sent successfully on local but not sent after deployed to live server.
  3. When you try to send email first time from live server then after first attempt to send email from live server go to your Gmail Account again and check activity and verify that its attempt is identify.
  4. After verify your attempt, the smtp server will sent email successfully from your live server.