In this article we will learn how to set up email address on godday hosting provider and to send emails using godaddy and asp .net. Godaddy is an internet domain registrar and hosting company. To send emails using godday one must have their website hosted at Godaddy hosting server.
Create a new email address on godaddy.
Step1: Logon to www.goddady.com and login to your account.
Step2: In you account section click on Launch button next to email tab.
Step3: Click on the create icon. A new popup window will appear.
Step4: Create a new email address and provide password.
Note: I have used above steps to create email and password on godaddy server. If you find any difficulties you can consult godaddy support.
Step5: Create a new asp .net website.
Step6: Add a new Default page. Paste following code to Default.aspx.
Step7: Paste following code to button click event.
protected void btnSendEmail_Click(object sender, EventArgs e)
{
MailMessage message = new MailMessage();
SmtpClient smtpClient = new SmtpClient();
string msg = string.Empty;
try
{
MailAddress fromAddress = new MailAddress("EmailAddressYouHaveCreatedOnGodaddy");
message.From = fromAddress;
message.To.Add(txtEmailTo.Text);
message.Subject = txtSubject.Text;
message.IsBodyHtml = true;
message.Body = txtEmailMessage.Text;
smtpClient.Host = "relay-hosting.secureserver.net"; //-- Donot change.
smtpClient.Port = 25; //--- Donot change
smtpClient.EnableSsl = false;//--- Donot change
smtpClient.UseDefaultCredentials = true;
smtpClient.Credentials = new System.Net.NetworkCredential("EmailAddressYouHaveCreatedOnGodaddy", "PasswordSuppliedDuringEmailCreation");
smtpClient.Send(message);
lblConfirmationMessage.Text = "Your email successfully sent.";
}
catch (Exception ex)
{
msg = ex.Message;
}
}
Note: This code will only works if you have uploaded your website to godaddy server (You cannot test this code from your local host).
For Testing of emails on local host you can follow these articles:
1) Top 10 email service providers to send emails using asp .net
2) Send test emails in asp .net without internet connectivity.
Final Output: