I am using asp.net 3.5 and c #.
I want to send mail from asp.net because I have some information from my hosting provider
which are as follows:
- mail.MySite.net
- Username
- Password
But I can not send mail through this data, I made the following changes in my web.config file:
<system.net>
<mailSettings>
<smtp>
<network
host="mail.MySite.net"
port="8080"
userName="UserName"
password="Password" />
</smtp>
</mailSettings>
</system.net>
Also, in the code behind, I am writing this function:
MailMessage mail = new MailMessage("webmaster@mySite.net", "XYZ@gmail.com");
mail.Subject = "Hi";
mail.Body = "Test Mail from ASP.NET";
mail.IsBodyHtml = false;
SmtpClient smp = new SmtpClient();
smp.Send(mail);
but I get an error when the message fails.
Please let me know what I am doing wrong and what I have to do to make it work properly.
Thanks in advance.
source
share