In one of my previous posts, I have explained how to send mail through GMail using ASP.NET C#. Well, for me it all looked good until I wanted to upload the application to GoDaddy server. I have Windows hosting plan there, and wanted to set the app for test purposes on it.
I’ve uploaded to GoDaddy both the application and the Web service I use to send mail. In service Web.config, the settings were something like this:
<system.net> <mailSettings> <smtp from="TEST" > <network host="smtp.gmail.com" port="587" userName="firstname.lastname@example.org" password="somepassword" defaultCredentials="false" /> </smtp> </mailSettings> </system.net>
But, I received the error message:
System.Web.Services.Protocols.SoapException: Server was unable to process request. —> System.Configuration.ConfigurationErrorsException: Insufficient permissions for setting the configuration property ‘port’.
So, I’ve Googled the exception in ‘GoDaddy context’ and learned that you can’t send e-mail through Gmail account using GoDaddy servers. Apparently, they want to prevent using their servers for sending spam. But, it wasn’t all so easy to understand it since I found some (for me) pretty vague answers. At first, I was convinced that you CAN send e-mails through GMail, because I found posts explaining how – but it just didn’t work for me! I even spoke to some friends who were sure this was working some time ago, when they needed to set up mail sending on GoDaddy. I tried several different configurations, but kept getting exceptions, different from the one I mentioned here.
Hours and hours later, I finally decided to give up on trying to use GMail. After all, this was all supposed to be just for testing. (When I make release version, I will buy ‘proper’ hosting.) I’ve created new e-mail account on my domain (also hosted on GoDaddy). I found out that, if you have the shared hosting plan, you must use their relay-hosting.secureserver.net on port 25. It’s important to say that this server doesn’t support SSL. So, in C# code, instead of
mailClient.EnableSsl = true;
it should be:
mailClient.EnableSsl = false;
In Web.config, the configuration will now be:
<system.net> <mailSettings> <smtp from="TEST" > <network host="relay-hosting.secureserver.net" port="25" userName="someuser@yourdomain" password="somepassword" defaultCredentials="false" /> </smtp> </mailSettings> </system.net>
Make sure to use the e-mail from your domain as sender, not the GMail! Also, set both username and password! I’ve found couple of comments from GoDaddy support team, explicitely saying you DON’T have to use credentials when configuring relay-hosting.secureserver.net. However, I couldn’t make it all work until I’ve set both username and password.
I must say that it took me a while to figure this out. I haven’t even thought of contacting GoDaddy support since I’ve been doing it a lot in last couple of months on various subjects and I’m pretty much tired of their responses ‘within 12 hours’. This is my first time trying to send mail from their server and it was all new to me, but I’ve discovered that this is a well known problem.
Hope this post will help people not to waste their precious time on a configuration issue like this.