I'm developing a website with ASP.NET 2005 and C#. I tried to send emails from my website
using the code I put in code section.
it gives me the follwing error:
"Bad sequence of commands. The server response was: This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server"
If I change the mairTo to "firstname.lastname@example.org
" which is my website, it'll work fine. But this way I can only send emails to my own website.!
Please help me how to solve my problem.
string mailFrom = "email@example.com";
string mailTo = "firstname.lastname@example.org";;
System.Net.Mail.MailMessage email = new System.Net.Mail.MailMessage("email@example.com", mailTo);
email.Subject = "subject";
email.IsBodyHtml = true;
email.Body = " body of the email";
System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient();
System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential("firstname.lastname@example.org", "my_password", "webmail.sharplabelcutter.com");
//mailClient.Host = "";
mailClient.Port = 25;
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = basicAuthenticationInfo;
catch (Exception ex)