信箱不可用。服务器响应为:bosauthsmtp05:主机117.58.242.18:不允许未经身份验证的中继

时间:2018-11-04 10:30:16

标签: asp.net

System.dll中发生类型'System.Net.Mail.SmtpException'的异常,但未在用户代码中处理 enter image description here 附加信息:邮箱不可用。服务器响应为:bosauthsmtp05:主机117.58.242.18:不允许未经身份验证的中继

1 个答案:

答案 0 :(得分:0)

尝试一下。

string to = "receiver@domain.com";

    //It seems, your mail server demands to use the same email-id in SENDER as with which you're authenticating. 
    //string from = "sender@domain.com";
    string from = "test@domain.com";

    string subject = "Hello World!";
    string body =  "Hello Body!";
    MailMessage message = new MailMessage(from, to, subject, body);
    SmtpClient client = new SmtpClient("smtp.domain.com");
    client.UseDefaultCredentials = false;
    client.Credentials = new NetworkCredential("test@domain.com", "password");
    client.Send(message);