In a recent project, you need to use the mailbox activation function, but there is a problem!
Problem Description: after sending the mailbox, the href attribute of the activation link of the mailbox is missing!!!
Because I used the local address to do the test, and then replaced my href address with Baidu's link.
Later Baidu, finally in an article to find the problem, address at the end of the article.
The reason is that when I write a url, if the access is local, I'm used to not adding http. If I don't add HTTP, I'll find the local resource, plus I'll find the resource through the HTTP protocol.
In the local mode, adding http will not be wrong, so for the url, adding http will not be wrong, not necessarily wrong.
I would like to avoid the next pit with this article!!!
Finally, the function code of sending email is attached:
1 /// <summary> 2 /// Send activation link 3 /// </summary> 4 /// <param name="mail">Destination email address</param> 5 /// <param name="Host">Activation address domain name</param> 6 /// <param name="UserID">User ID ID</param> 7 public static void SendEmail(string mail, string Host, int? UserID) 8 { 9 //Randomly generate mailbox activation code 10 string ActiCode = Guid.NewGuid().ToString("N"); 11 //Splicing mailbox activation link 12 formto = string.Format(formto, Host, UserID, ActiCode); 13 MailMessage mailMsg = new MailMessage(); 14 mailMsg.From = new MailAddress(name);//Source email address ,Sender 15 mailMsg.To.Add(new MailAddress(mail));//Destination email address. Can have multiple recipients. 16 mailMsg.Subject = "Display expert email activation verification";//Send the title of the message 17 mailMsg.Body = "Please verify your email,To activate the email you used to receive relevant information in the display expert, click the following link to activate your email:<br><a target='_blank' style='color:#0041D3;text-decoration:underline' href='"+formto+"'>Please click activate</a>";//Send message content 18 mailMsg.IsBodyHtml = true; 19 SmtpClient client = new SmtpClient(smtp);//smtp.163.com,smtp.qq.com,Of the mailbox used by the sender SMTP The server. 20 client.Credentials = new System.Net.NetworkCredential(name, upass);//Specify the sender's email account and password. 21 client.Send(mailMsg);//Queued mail. 22 }
Sprout a new one, please give me more advice!
It is reproduced in: https://blog.csdn.net/sirytao/article/details/80017215