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

后端 未结 6 1517
南旧
南旧 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:39

    Have you tried setting your auth credentials in the web.Config?

      
        
          
            
          
        
      
    

    and your code behind

    MailMessage message = new MailMessage();
    message.From = new MailAddress("sender@foo.bar.com");
    message.To.Add(new MailAddress("recipient1@foo.bar.com"));
    message.To.Add(new MailAddress("recipient2@foo.bar.com"));
    message.To.Add(new MailAddress("recipient3@foo.bar.com"));
    message.CC.Add(new MailAddress("carboncopy@foo.bar.com"));
    message.Subject = "This is my subject";
    message.Body = "This is the content";
    SmtpClient client = new SmtpClient();
    client.Send(message);
    

提交回复
热议问题