i'm trying to send email from web Application deployed in Godaddy Windows 2012 Vitual Private Server.
Error Displayed "Server actively refused the connection".
Email send from my local system, but outgoing email is not working on Godaddy Hosting.
using (var smtp = new SmtpClient()) {
var credential = new NetworkCredential {
UserName = "user@outlook.com",
Password = "password" };
smtp.Credentials = credential;
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
await smtp.SendMailAsync(message);
return RedirectToAction("Sent");
}
Firstly, try adding:
smtp.UseDefaultCredentials = false;
Before:
smtp.Credentials = credential;
Since June of 2016, Gmail changed its DMARC policy from p="none"
to p="reject"
.
Any emails sent using a from address ending with @gmail.com
, will have to originate from within Gmail's infrastructure.
You will need to use an email sending service, such as SendGrid (www.sendgrid.com) or mailgun (www.mailgun.com).
You should be using one of these anyway, as they help you keep off spam blacklists and provide lots of other benefits, including details of showing you if emails have been blocked due to bad email addresses, spam reports, etc.
More information on what DMARC is and how it works is available in this article on the Sendgrid blog.