Wednesday, November 9, 2011

GoDaddy email error : 553 sorry, your mail was administratively denied

In the previous post I explained about sending SMTP mail from ASP.NET. When I use it in Arvixe web hosting, it went well. But, I happened to try GoDaddy web hosting with the same source code. Then now I got the the following exception : 553 sorry, your mail was administratively denied. There have been some complaint about this problem. With some struggle, I ended up with the following workaround.

(1) GoDaddy SMTP server settings in web.config are as follows. Please note that you do not need username and password information here.

<system.net>
   <mailSettings>
     <smtp>
       <network host="relay-hosting.secureserver.net" port="25" />
      </smtp>
</mailSettings>
</system.net>
(2) I used Contact Form in ASP.NET and took FROM email address from textbox, which most people do. The thing is GoDaddy mail system denied this kind of email address.

string from = txtEmail.Text.Trim();               
string subject = txtSubject.Text.Trim();               
string body = txtMsg.Text;
string to = WebConfigurationManager.AppSettings["MailAccount"];
body = string.Format("From: {0}{1}{2}", from, Environment.NewLine, body);               
from = to;  // Do not use user's email address
MailMessage message = new MailMessage(from, to, subject, body);
SmtpClient smtp = new SmtpClient();
smtp.Send(message);

So the workaround is to use my domain email account in FROM part and put the customer's email to subject or body part. I don't like it but it worked anyway...

No comments:

Post a Comment