QQ mailbox POP3 and SMTP server address settings are as follows: Mailbox POP3 Server (port) SMTP server (port) Qq.compop.qq.comsmtp.qq.comSMTP server requires authentication.
If you are setting up SSL encryption for POP3 and SMTP, the ports are as follows:
POP3 Server (Port 995)
SMTP Server (port 465 or 587).
QQ mailbox to pay attention to open the following services: QQ will give you an authorization code, in the following code in detail where to use this authorization code.
Code in Controller:
A using system.net.mail;//message is sent by referring to the public ActionResult bindStep3 (Modelcompany c) {.....
........... MailAddress messagefrom = new MailAddress ("xxxxx@qq.com"); Sender's mailbox address string messageto = Company.company_email; Recipient mailbox Address String messagesubject = "Activation Verification"; Message subject String messagebody = "Please verify the mailbox to complete the final step of your registration, click the link below to activate your account: <br><a target= ' _blank ' rel= ' nofollow" style= ' Color: #0041D3; Text-decoration:underline ' href= ' > Activation </a>; Mail content (usually a URL link, generate random number and verify ID parameters, click to verify the site.) if (SendMail (Messagefrom, Messageto, MessageSubject, MessageBody)) {Response.Write ("<script type= ' te
Xt/javascript ' >alert (' send mail failed ');</script> ");
else {Response.Write ("<script type= ' text/javascript ' >alert (' send mail failed ');</script>");
} tempdata["CompanyBind3"] = Company;
Return View ("BindStep3"); public bool SendMail (mailaddress messagefrom,string messageto,string MessageSUbject,string messagebody)//Send verification Email {MailMessage message = new MailMessage (); Message.
To.add (Messageto); Message.
from = Messagefrom; Message.
Subject = MessageSubject; Message.
subjectencoding = System.Text.Encoding.UTF8; Message.
BODY = MessageBody; Message.
bodyencoding = System.Text.Encoding.UTF8; Message. Isbodyhtml = true; is an HTML format message. Priority = Mailpriority.high;
Priority for sending mail SmtpClient sc = new SmtpClient (); Sc. Enablessl = true;//whether SSL encrypts SC. Host = "smtp.qq.com"; Specifies the server address or IP SC that sends the message. Port = 587; Specifies the Send mail port SC. Credentials = new System.Net.NetworkCredential ("xxxxx@qq.com", "xxxxx"); Specify the username and password for the login server (note: The password here is to open the POP3/SMTP service provided to you by the authorization password, not your QQ password) try {sc. Send (message);
Send messages} catch (Exception e) {Response.Write (e.message);
return false;
return true;
}
Implementation effect:
Reference articles:
Http://www.jb51.net/article/83796.htm
Http://www.jb51.net/article/83801.htm
The above is the entire content of this article, I hope that you learn asp.net mvc to send mail help.