Friday, July 13, 2012

Sending Email from GoDaddy Windows Shared Hosting using asp.net 3.5

 

The server "relay-hosting.secureserver.net" is used to send email from your hosted domain on GoDaddy.com servers. You must populate the SmtpMail object's SmtpServer property with this value.

 

// import namespace
using System.Web.Mail;
private void SendEmail()
{
   const string SERVER = "relay-hosting.secureserver.net";
   MailMessage oMail = new System.Web.Mail.MailMessage();
   oMail.From = "emailaddress@domainname";
   oMail.To = "emailaddress@domainname";
   oMail.Subject = "Test email subject";
   oMail.BodyFormat = MailFormat.Html; // enumeration
   oMail.Priority = MailPriority.High; // enumeration
   oMail.Body = "Sent at: " + DateTime.Now;
   SmtpMail.SmtpServer = SERVER;
   SmtpMail.Send(oMail);
   oMail = null; // free up resources
}



Note: GoDaddy servers will not send email containing a “From:” header entry of gmail, yahoo, hotmail, live, aim, aol or msn.

Happy Coding…

1 comment:

  1. Bluehost is ultimately the best hosting company with plans for all of your hosting needs.

    ReplyDelete