72117

Sent mail using smtp not working when deployed in microsoft windows azure c# asp.net mvc5

Question:

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 : <a href="http://www.postseek.com/meta/488719217d716a4fc35c7d6f336e263c" rel="nofollow">http://www.postseek.com/meta/488719217d716a4fc35c7d6f336e263c</a>" I want to know is that correct?? Would i use another sent mail server?

Answer1:

SMTP probably isn't supported.

You could us <a href="https://mandrillapp.com/" rel="nofollow">Mandrill</a> they have an api that you can use to send email that works over http, so you don't need to worry about smtp.

Answer2:

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("jon@doe.com", "password"), EnableSsl = true <br/> };<br/> client.Send(email, "ToAddress@gmail.com", subject, message); <br/> return Task.FromResult(0); <br/> } <br/> }

Recommend

  • I need to create a mailto link from PHP code
  • My Mails Is Always Going To Spam Folder Even Delivering Very Late In Codeigniter Php
  • php.ini, sendmail configuration to send an email using a php script
  • Codeigniter email - browser keeps on loading
  • ASP.NET C# - Dropdown list by using User Control
  • How to get display-name from web.xml in a Spring IoC XML Configuration
  • Error publishing to Azure cloud service with osFamily=5
  • How Fade in UIButton
  • zend smtp mail crashes after 100+ mails
  • Image in Email Subject using PHP
  • Eclipse and Zend Debugger breaks in the first line always, despite having unchecked that option
  • In regards to the difference between Java “Properties” and C#' Properties
  • Mongolab connection error
  • Bluebird: getting the results of each()
  • How to configure Monolog to send errors via SwiftMailer to alternate mailer in Symfony2
  • Notification.alert is not working in phonegap build 3.1.0
  • shared preferences for storing a single score
  • hibernate.properties does not found in maven project using hibernate
  • Found com.google.android.gms:play-services-places:9.2.1, but version 9.0.2 is needed for the google-
  • Hibernate - Cannot connect to DB
  • What is the right syntax for “timeframe” in MailChimp API 3.0
  • SmtpClient sends email to junk
  • UIButton Borders Function Only Gives Back White Borders
  • AWS-SES: Handling Bounces for Invalid ISPs
  • testing a POST using phpunit in laravel 4
  • Getting unread count in Sent Folder using Google Apps Script - GMail
  • How to resolve this packager error on react native Android
  • jersey/tomcat Description The origin server did not find a current representation for the target res
  • Unable to connect to OnVif enabled camera using C#
  • .NET video play library which allows to change the playback rate?
  • Getting different value with placeholder over CPU/GPU
  • Installing PHP 7 on digitalocean
  • Problems installing Yesod for Haskell
  • Mysterious problem with floating point in LISP - time axis generation
  • Email verification using google app script and google forms
  • Bitwise OR returns boolean when one of operands is nil
  • sending mail using smtp is too slow
  • Busy indicator not showing up in wpf window [duplicate]
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How can I use `wmic` in a Windows PE script?