Send Emails using Godaddy in asp .net

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.


Send emails using godaddy and asp net

 

Step3: Click on the create icon. A new popup window will appear.


Send emails using godaddy and asp net

 

Step4: Create a new email address and provide password.


Send emails using godaddy and asp net

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.

 

  
Email To
Subject
Message
 

 

 

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: 


Send emails using godaddy and asp net
 

About Us | Terms of Use | Privacy Policy | Disclaimer | Contact Us Copyright © 2012-2024 CodingFusion
50+ C# Programs for beginners to practice