If server is unsecure dont need SMTP credentials or SSL enabled.
For example if using google:
SMTP = smtp.gmail.com
credentialsUN = johnilett@gmail.com
credentialsPW = YOURPASSWORD
returnEmail = noreply@gmail.com - Dummy
using System.Net.Mail;
protected void mail(string email, string name)
{
getCredentials();
MailMessage mail = new MailMessage();
mail.To.Add(email);
mail.From = new MailAddress(credentialsUN);
mail.ReplyTo = new MailAddress(credentialsUN);
mail.Subject = "HR DW Website Password";
mail.IsBodyHtml = true;
string Body = "<~html~><~/body~>Dear " + name + "," + "<~br /~>" + "<~br /~>" + "Your password for the HR DW website is: " + "" + "<~b~>" + password + "<~/b~>";
Body += "<~br /~>" + "<~br /~>" + "Thanks," + "<~br /~>" + "HR DW Support.<~/body~><~/html~>";
mail.Body = Body;
SmtpClient smtp = new SmtpClient();
smtp.Host = credentialsSMTP;
//Dont need these 2 if unsecure SMTP
smtp.Credentials = new System.Net.NetworkCredential(credentialsUN, credentialsPW);
smtp.EnableSsl = true;
smtp.Send(mail);
}
*replace ~ with ""
No comments:
Post a Comment