Qq mail verification code and email Verification Code

Source: Internet
Author: User
Tags account security mailmessage smtpclient

Qq mail verification code and email Verification Code

Sometimes the memory of a person is the same as that of a fish. It takes only seven seconds and a short time!

. NET Web form implementation forgot password, use QQ mailbox verification to modify

1. First, set the email address for sending an individual or enterprise email.

2. Set the logon email address,

3. Disable email

4. Start to write code...

1. A simple front-end design

 

2. The background first references the namespace

Using System. Net;
Using System. Net. Mail;

/// <Summary>
/// Send the verification code
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "e"> </param>
Protected void button#click (object sender, EventArgs e)
{
// Message sent
This. Label1.Text = "* The verification code has been sent to your mailbox. Check it carefully! ";
// Generate a random Verification Code
Int num;
String str = string. Empty;
Random rm = new Random ();
For (int I = 0; I <6; I ++)
{
Num = Convert. ToInt32 (rm. NextDouble () * 10 );
Str + = num;
}
Session ["Rom"] = str;
String content = "*** technology reminds you that you are using the account security verification service. Your verification code for this operation is:" + str;
// Recipient's email address, email title, and email content
SendEmail1 ("xxx@qq.com", "[Xiaozhang technology] background login modify user information prompt", content );
}

 

/// <Summary>
/// Send the email Verification Code
/// </Summary>
/// <Param name = "mailTo"> recipient </param>
/// <Param name = "mailSubject"> title </param>
/// <Param name = "mailContent"> content </param>
///
Public static void SendEmail1 (string mailTo, string mailSubject, string mailContent)
{
SmtpClient mailClient = new SmtpClient ("smtp.qq.com ");
MailClient. EnableSsl = true;
MailClient. usedefacrecredentials = false;
// Credentials logs on to the SMTP server for authentication.
MailClient. Credentials = new NetworkCredential ("xxx@qq.com", "suzgotcsfwbpbbec"); // mailbox,
MailMessage message = new MailMessage (new MailAddress ("xxx@qq.com"), new MailAddress (mailTo); // sender, recipient
Message. IsBodyHtml = true;
Message. Body = mailContent; // mail content
Message. Subject = mailSubject; // mail Subject
MailClient. Send (message); // Send an email
}

 

/// <Summary>
/// Log on
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "e"> </param>
Protected void Button2_Click (object sender, EventArgs e)
{
If (TextBox1.Text. Trim () = Session ["Rom"]. ToString ())
{
Response. Write ("<script> alert (\" Verification Successful! \ "); </Script> ");
This. Label1.Text = "";
}
Else
{
Response. Write ("<script> alert (\" Verification Failed! \ "); </Script> ");
This. Label1.Text = "* Incorrect verification code. Enter again! ";
}
}

This is the end and you can run it.Welcome to join us!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.