MailKit it's worked on local pc only, but don't work on live server (2016) on azure.
When i tested on windows 10 email send is correct, but when we try to deploy to production server
on Azure we can't send email.
I don't make sure IIS on the server block the email service ?
We tried to enable SMTP on server but it's not help.



Best,
Uthen
Sample code we used:
public class EMailSender
{
public async Task SendEmailByThread(string sSubject, string sHtmlBody,
string sFromEmail, string sToEmail, string sFromName, string sToName,
string sAuthenPassword, int nPort, string sSMTP)
{
var message = new MimeMessage();
message.From.Add(new MailboxAddress(sFromName, sFromEmail));
message.To.Add(new MailboxAddress(sToName, sToEmail));
message.Subject = sSubject;
var bodyBuilder = new BodyBuilder();
bodyBuilder.HtmlBody = sHtmlBody;
message.Body = bodyBuilder.ToMessageBody();
using (var client = new SmtpClient())
{
await client.ConnectAsync(sSMTP, nPort, false);
// Note: since we don't have an OAuth2 token, disable
// the XOAUTH2 authentication mechanism.
client.AuthenticationMechanisms.Remove("XOAUTH2");
await client.AuthenticateAsync(sFromEmail, sAuthenPassword);
client.Send(message);
client.Disconnect(true);
}
}
}
relate on this number or not ? https://github.com/jstedfast/MailKit/issues/393
I try on this but don't help.: http://stackoverflow.com/questions/35651001/gmail-smtpauthenticationerror-when-i-attempt-to-send-email-via-django
GMail blocks logins from unknown IP addresses. You need to login to your GMail account from your azure server first. Then it will work.
@jstedfast unbelievable it's worked wowwwwwwww and cool.
You save my day & night 馃憤
you're welcome!
@jstedfast It's worked good on azure, but it's not work on amazon ec2 ?
You need to allow access to the Gsuit Gmail account, because, google blocks the mail from different IP's.
@jstedfast unbelievable it's worked wowwwwwwww and cool.
You save my day & night 馃憤
How did you logged in from Azure?
Most helpful comment
You need to allow access to the Gsuit Gmail account, because, google blocks the mail from different IP's.
https://accounts.google.com/DisplayUnlockCaptcha