How to send mail from Domain server in c#?

How to send mail from Domain server in c#?

Asked by:- RameshwarLate
: 4444 At:- 12/15/2017 5:55:24 AM
asp c#

2 Answers
profileImage Answered by:- Sam

Sending mail from domain server is similar to sending emails using Gmail, just a difference is each domain uses a different port, different configuration, it should match your code, suppose your Email is on GoDaddy then using

host="" port="25"

1- If your site is hosted on GoDaddy you may use "" without credentials.

2- If your site is hosted outside of GoDaddy you may use "" with your email account credentials.

Hosted On GoDaddy

       <smtp from="">
        <network host=""/>


      <smtp from="">
        <network host="" 
           userName="" password="your_password_here" 
           port="25" />

Complete C# Code (When it has Godaddy Email Hosting & the Website is Hosted on Godaddy, you can change port number and hosting as per your host)

using System;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Net;
public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e){}
    protected void btnSubmit_Click(object sender, EventArgs e)
            //Create the msg object to be sent
            MailMessage msg = new MailMessage();

            //Add your email address to the recipients

            //Configure the address we are sending the mail from
            MailAddress address = new MailAddress("");
            msg.From = address;
            msg.Subject = txtSubject.Text;
            msg.Body = txtName.Text + "n" + txtEmail.Text + "n" + txtMessage.Text;
    	    SmtpClient client = new SmtpClient();
    	    client.Host = "";
    	    client.Port = 25;
            //Send the msg
            //Display some feedback to the user to let them know it was sent
            lblResult.Text = "Your message was sent!";
        catch (Exception ex)
            //If the message failed at some point, let the user know
            lblResult.Text = ex.ToString(); //alt text "Your message failed to send, please try again."

You may also need to look at the answer's provided here

Article on sending email (which should work considering above comments)

If you are hosting on GoDaddy, here is the complete example (First part only)

Article, by GoDaddy itself

At:- 12/15/2017 7:55:02 AM Updated at:- 12/26/2017 2:01:55 PM

profileImage Answered by:- user_898002883

The fast and easy way to manage feedback and approval of pdf files, images and other creative projects. Speed up your design reviews for print, digital, and website projects. Discover the best design feedback tools for every designer. Visit:

At:- 9/1/2022 9:02:38 AM

Login/Register to answer
Register directly by posting answer/details

Full Name *

Email *

By posting your answer you agree on privacy policy & terms of use