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>
This is likely a reply from the SMTP server because the machine attempting to send email has not been whitelisted (or is blacklisted for SPAM). Is relay-hosting.secureserver.net a GoDaddy server, or is it on a different network? You might want to find a GoDaddy server that enables email to be relayed. I would imagine a lot of shared hosting providers have restrictions today.
I would find out what type of SMTP server you are using and what anti-spam measures are in place. The administrator may be able to add the GoDaddy server to the whitelist of allowed hosts. You need to be very careful and make sure that you application cannot be used as a proxy for a spammer. Make sure to validate all input to ensure it it safe.
For those who want to know what should be C# code in addition to the accepted answer, below code worked for me. Please note that "from" address is already mentioned in web.config in the accepted answer, so no need to mention it in C# code.
Just for a test. Remove the username and password values from the web.config.
Then, in your code set
Try below code:
It worked for me.
I just asked GoDaddy, how to set up a SMTP form mailer, and they told me that I'd need to use a Relay Server, with no username, no password, and no port. The server name to use was, the same name that you used.