Ramesh gawade

Ramesh gawade

  • 1.6k
  • 132
  • 49k

Mail sending

Jan 11 2016 2:26 PM
how to send mail on server
 
private void SendActivationEmail(string b)
{
//string constr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
//// string activationCode = Guid.NewGuid().ToString();
//using (SqlConnection con = new SqlConnection(constr))
//{
//}
using (MailMessage mm = new MailMessage("[email protected]", "tomail"))
{
mm.Subject = "Mavro Commitement OTP";
string body = "<div align='center' style='border:1px solid #22313F; background-color:#22313F;'><b style='color:white;background-color:#22313F;width:100%;hieght:40px; font-size:35px;'><a href=www.mavromining.org style='text-decoration:none;'> MavroMining.Org </a></b> </div> ";
body += "<div style='background-color:#E2EBFA;'><b style='margin-top:40PX; margin-left:60px;'>Your Generated One Time Password is: </b>";
body += "<br />";
body += "<br /><br /><b style='margin-top:40PX; margin-left:60px;'>Thanks </b></div>";
mm.Body = body;
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "mail.mavromining.com";
smtp.EnableSsl = true;
NetworkCredential NetworkCred = new NetworkCredential("[email protected]", "*******");
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 25; //smtp.Port = 587
smtp.Send(mm);
}
}
 
 
 
gives error:---

Server does not support secure connections  port:25

and
 
No connection could be made because the target machine actively refused it port:587 
   
 
 
please provide me solution of this problem 
 

Answers (2)