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

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 = "[email protected]";

//It seems, your mail server demands to use the same email-id in SENDER as with which you're authenticating. 
//string from = "[email protected]";
string from = "[email protected]";

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("[email protected]", "password");
client.Send(message);

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

  <system.net>
    <mailSettings>
      <smtp from="[email protected]">
        <network host="smtpserver1" port="25" userName="username" password="secret" defaultCredentials="true" />
      </smtp>
    </mailSettings>
  </system.net>

and your code behind

MailMessage message = new MailMessage();
message.From = new MailAddress("[email protected]");
message.To.Add(new MailAddress("[email protected]"));
message.To.Add(new MailAddress("[email protected]"));
message.To.Add(new MailAddress("[email protected]"));
message.CC.Add(new MailAddress("[email protected]"));
message.Subject = "This is my subject";
message.Body = "This is the content";
SmtpClient client = new SmtpClient();
client.Send(message);

Try this:

string to = "[email protected]";
string from = "[email protected]";
string subject = "Hello World!";
string body =  "Hello Body!";
MailMessage message = new MailMessage(from, to, subject, body);
SmtpClient client = new SmtpClient("smtp.domain.com");
// explicitly declare that you will be providing the credentials:
client.UseDefaultCredentials = false;
// drop the @domain stuff from your user name: (The API already knows the domain
// from the construction of the SmtpClient instance
client.Credentials = new NetworkCredential("test", "password");
client.Send(message);

Tags:

C#

Smtpclient