How to send mail from Domain server in Asp.net c#?
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="relay-hosting.secureserver.net" port="25"
1- If your site is hosted on GoDaddy you may use "relay-hosting.secureserver.net" without credentials.
2- If your site is hosted outside of GoDaddy you may use "smtpout.secureserver.net" with your email account credentials.
Hosted On GoDaddy
<system.net>
<mailSettings>
<smtp from="abc@xyz.net">
<network host="relay-hosting.secureserver.net"/>
</smtp>
</mailSettings>
</system.net>
External
<system.net>
<mailSettings>
<smtp from="abc@xyz.net">
<network host="smtpout.secureserver.net"
userName="abc@xyz.net" password="your_password_here"
port="25" />
</smtp>
</mailSettings>
</system.net>
Complete asp.net 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)
{
try
{
//Create the msg object to be sent
MailMessage msg = new MailMessage();
//Add your email address to the recipients
msg.To.Add("sam@gmail.net");
//Configure the address we are sending the mail from
MailAddress address = new MailAddress("info@domain.com");
msg.From = address;
msg.Subject = txtSubject.Text;
msg.Body = txtName.Text + "n" + txtEmail.Text + "n" + txtMessage.Text;
SmtpClient client = new SmtpClient();
client.Host = "relay-hosting.secureserver.net";
client.Port = 25;
//Send the msg
client.Send(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
https://qawithexperts.com/questions/152/how-to-send-mail-from-domain-server-in-aspnet-c
Article on sending email (which should work considering above comments)
https://qawithexperts.com/article/asp.net/send-email-using-c-mvc-net/16
If you are hosting on GoDaddy, here is the complete example (First part only)
http://vandelayweb.com/sending-asp-net-emails-godaddy-gmail-godaddy-hosted
Article, by GoDaddy itself https://in.godaddy.com/help/send-email-using-systemnetmail-19291
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: https://www.cheapwebhosting.services/
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly