尝试从门户发送邮件时收到错误消息?

时间:2018-12-18 12:07:12

标签: c# asp.net .net smtp

我使用以下代码发送sendmailasync:

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

有什么主意,为什么我会得到上面的错误以及如何解决?

0 个答案:

没有答案
相关问题