When I try to sendmail using asp.net I get the following error.
Error Details: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: Relaying not allowed
I have used the right credentials (through which we could access web mail)
I have configured the mail using Google Labs. Does this affect anyway?
MailMessage mailMsg = new MailMessage();
mailMsg.From = new MailAddress("info@thewebsite.com", "thewebsite.com");
mailMsg.To.Add(new MailAddress(ToAddress));
mailMsg.Subject = Subject;
mailMsg.BodyEncoding = System.Text.Encoding.GetEncoding("utf-8");
System.Net.Mail.AlternateView plainView = System.Net.Mail.AlternateView.CreateAlternateViewFromString
(System.Text.RegularExpressions.Regex.Replace(BodyText, @"<(.|\n)*?>", string.Empty), null, "text/plain");
System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(BodyText, null, "text/html");
mailMsg.AlternateViews.Add(plainView);
mailMsg.AlternateViews.Add(htmlView);
// Smtp configuration
SmtpClient smtp = new SmtpClient();
smtp.UseDefaultCredentials = true;
string smtphost = System.Configuration.ConfigurationManager.AppSettings["smtphost"].ToString();
int smtpport = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["smtpport"].ToString());
smtp.Host = smtphost;
smtp.Port = smtpport;
smtp.Credentials = new System.Net.NetworkCredential("info@thewebsite.com", "pwd1234");