Troubleshooting “Mailbox unavailable. The server response was: Access denied - Invalid HELO name” when sending email with SmtpClient

后端 未结 6 1582
南旧
南旧 2021-01-11 18:24

I have been trying to send an email by C#. I have Googled for various examples and have taken bits and pieces from each and from the standard code which everyone would most

6条回答
  •  温柔的废话
    2021-01-11 18:42

    It seems your username/password pair is not authenticating successfully with your SMTP server.

    EDIT

    I think, I found what's wrong here. I have corrected your version below.

    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);
    

提交回复
热议问题