/// <summary>
/// 注册时发送用户帐号跟密码
/// </summary>
/// <param name="receiver">用户注册邮箱</param>
/// <param name="username">用户名</param>
/// <param name="password">用户密码明文</param>
public bool Register(string receiver, string username, string password)
{
System.Net.Mail.SmtpClient client;
client = new System.Net.Mail.SmtpClient("smtp.126.com");
client.Timeout = 60000;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("邮箱号", "邮箱密码");
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.SubjectEncoding = System.Text.Encoding.UTF8;
message.BodyEncoding = System.Text.Encoding.UTF8;
message.From = new System.Net.Mail.MailAddress("邮箱号", "显示名称", System.Text.Encoding.UTF8);
message.To.Add(new System.Net.Mail.MailAddress(receiver, username, System.Text.Encoding.UTF8));
message.IsBodyHtml = false;//是否html编码
message.Subject = "用户注册信息";
message.Body = username + ":您好!/r/n 您注册的用户名是:" + username + ";密码是:" + password + "。/r/n ";
try
{
client.Send(message);
Response.Write("发送成功!");
return true;
}
catch
{
return false;
}
}