views:

424

answers:

2

SMTP is a whole new ballgame for me, but I am reading up on it.

I am attempting to send email from my EC2 instance using GoDaddy's SMTP server. My domain name is registered through GoDaddy and I have 2 email accounts with them.

I can successfully send the email from my dev box no problem.

my web.config

 <system.net>
    <mailSettings>
      <smtp from="[email protected]" deliveryMethod="Network">
        <network host="smtpout.secureserver.net" clientDomain="mydomain.com" port="25" userName="[email protected]" password="mypassword" defaultCredentials="false" />
      </smtp>
    </mailSettings>
  </system.net>

In my ASP.NET app:

MailMessage mailMessage = new MailMessage("[email protected]", recipientEmail, emailSubject, body);
mailMessage.IsBodyHtml = false;

SmtpClient mailClient = new SmtpClient();
mailClient.Send(mailMessage);

Very typical, simple use of System.Net.Mail.SmtpClient. The mail client is picking up the settings from my web.config as expected.

From the EC2 instance, the same setup yields:

System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed.
   at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine)
   at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine)
   at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller)
   at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
   at System.Net.Mail.SmtpClient.Send(MailMessage message)
   --- End of inner exception stack trace ---

I have searched high and low and not found anyone else attempting this. All GoDaddy smtp situations I have found involve people being hosted by GoDaddy using their relay server.

Some more info:

  • My EC2 instance is Windows Server 2008 with IIS 7. The app is running in .NET 4
  • I can successfully use Gmail's SMTP server on the EC2 instance by using their port, setting SmtpClient.EnableSsl to true, and sending the mail through a gmail account. But we want to send the email from an account on our domain.
  • I have port 25 open on both the Windows firewall and Amazon's Security group based firewall.
  • I have played with Wireshark and noticed my SMTP related traffic was talking to ports in the 5,000s, so out of desperation I opened them all up to no avail (then closed them back down)
  • As far as I know my EC2 instance's IP address is not black listed by GoDaddy or by anyone else.

I have a feeling I'm just missing something fundamental. I also have a feeling someone is going to recommend I use AuthSmtp or something similar, I'll agree, and have had wasted the past 6 hours :)

+1  A: 

You have to use a valid e-mail address on your domain as the "from" address. You can't use another, for instance, a user's e-mail from an online correspondence form.

Yes, it sucks.

TheGeekYouNeed
Yeah I am using a valid address. "[email protected]" (with my actual domain name of course) is a real address.
Matt Greer
I've only had success with GoDaddy using this SMTP value: relay-hosting.secureserver.net
TheGeekYouNeed
When you used that server, was it from a box that was being hosted by GoDaddy? I'll give it a shot. Thanks.
Matt Greer
Yes it was hosted by GoDaddy
TheGeekYouNeed
A: 

I'm having the exact same problem on EC2. From my dev box it works fine off of EC2.

I'm using Ubuntu and PHP. I have tried telnet smtpout.secureserver.net 25 and the connection is closed immediately. This tells me the problem isn't on our end in the code.

I've been fighting this for two days and am no closer to a solution.