Jared Jared - 3 months ago 46
ASP.NET (C#) Question

Cannot send email in ASP.NET through Godaddy servers

I have an ASP.NET application hosted on Godaddy that I want to send email from. When it runs, I get: Mailbox name not allowed. The server response was: sorry, relaying denied from your location. The important parts of the code and Web.config are below:

msg = new MailMessage("accounts@greektools.net", email);
msg.Subject = "GreekTools Registration";
msg.Body =
"You have been invited by your organization to register for the GreekTools recruitment application.<br/><br/>" +
url + "<br/><br/>" +
"Sincerely,<br/>" +
"The GreekTools Team";

msg.IsBodyHtml = true;

client = new SmtpClient();
client.Host = "relay-hosting.secureserver.net";

client.Send(msg);

<system.net>
<mailSettings>
<smtp from="accounts@greektools.net">
<network host="relay-hosting.secureserver.net" port="25" userName="********" password="*********" />
</smtp>
</mailSettings>



Answer

1- If your site is hosted on godaddy you may use "relay-hosting.secureserver.net" without credentials.

2- If your site is hosted outside of godaddy you may use "smtpout.secureserver.net" with you email account credentials.

PS: Please change port 3535 if you have problems with 25

Hosted On GoDaddy

    <system.net>
      <mailSettings>
       <smtp from="abc@xyz.net">
        <network host="relay-hosting.secureserver.net"/>
       </smtp>
      </mailSettings>
    </system.net>

External

  <system.net>
    <mailSettings>
      <smtp from="abc@xyz.net">
        <network host="smtpout.secureserver.net" 
           userName="abc@xyz.net" password="your_password_here" 
           port="25" />
      </smtp>
    </mailSettings>
  </system.net>