I tried to send an email using this class below, but no success, no error message, the page just executed very fast, any problem with this class?
public bool mailSender(string strSubject, string strFrom, string strFromName, string strTo, string strBody)
{
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
try
{
MailAddress fromAddress = new MailAddress(strFrom, strFromName);
smtpClient.Host = ConfigurationManager.AppSettings["smtpServer"];
smtpClient.Port = 25;
smtpClient.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["smtpUsername"], ConfigurationManager.AppSettings["smtpPassword"]);
message.From = fromAddress;
message.To.Add(strTo);
message.Subject = strSubject;
message.IsBodyHtml = false;
message.Body = strBody;
smtpClient.Send(message);
return true;
}
catch
{
return false;
}
}