Я использую этот код для sentmailasync:
public class EmailService : IIdentityMessageService
{
public Task SendAsync(IdentityMessage message)
{
//// Plug in your email service here to send an email.
//return Task.FromResult(0);
//Login password of sender
var from = ConfigurationManager.AppSettings["email"];
var pass = ConfigurationManager.AppSettings["e_password"];
//set address and port smtp-server from wich main is sent
SmtpClient client = new SmtpClient("smtp-mail.outlook.com");
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential(from, pass);
client.EnableSsl = true;
//creating massage and destination address
var mail = new MailMessage(from, message.Destination);
mail.Subject = message.Subject;
mail.Body = message.Body;
mail.IsBodyHtml = true;
return client.SendMailAsync(mail);
}
}
Я опубликовал код в двух производствах в одной машине, он работает нормально.
В других машинах я получаю эту ошибку:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 40.100.172.242:587
Есть идеи, почему я получаю ошибку выше и как ее исправить?