In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "asp.net mvc how to send email", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "asp.net mvc how to send email" this article.
QQ Mail POP3 and SMTP server addresses are set as follows: mailbox POP3 server (port 110) SMTP server (port 25) qq.compop.qq.comsmtp.qq.comSMTP server requires authentication.
If you set the SSL encryption method for POP3 and SMTP, the ports are as follows:
POP3 server (port 995)
SMTP server (port 465 or 587).
QQ Mail should pay attention to opening the following service: qq will give you an authorization code, which will be used in detail in the following code.
Code in the controller:
Using System.Net.Mail;// email needs to refer to public ActionResult bindStep3 (ModelCompany c) {. . . MailAddress MessageFrom = new MailAddress ("xxxxx@qq.com"); / / Sender email address string MessageTo = company.COMPANY_EMAIL; / / recipient email address string MessageSubject = "Activation Verification"; / / email subject string MessageBody = "Please verify your email address to complete the last step of your registration, click the link below to activate your account:
Activate "; / / email content (usually a URL link, generate a random number plus a verification id parameter, click to go to the website to verify. ) if (SendMail (MessageFrom, MessageTo, MessageSubject, MessageBody)) {Response.Write ("alert ('failed to send email');");} else {Response.Write ("alert ('failed to send email');");} 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 / / whether it is in html format message.Priority = MailPriority.High; / / priority for sending mail SmtpClient sc = new SmtpClient (); sc.EnableSsl = true;// whether SSL encryption sc.Host = "smtp.qq.com"; / / specify the address of the server to send the mail or IP sc.Port = 587 / / specify the sending mail port sc.Credentials = new System.Net.NetworkCredential ("xxxxx@qq.com", "xxxxx"); / / specify the user name and password to log in to the server (Note: the password here is the authorization password provided to you by activating the pop3/smtp service above, not your qq password) try {sc.Send (message) / / send email} catch (Exception e) {Response.Write (e.Message); return false;} return true;}
Achieve results:
The above is all the contents of the article "how to send email by asp.net mvc". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.