Thinkphp 163 and QQ mail sending and receiving methods

Source: Internet
Author: User
Tags imap
This article mainly introduces thinkphp's method of sending and receiving emails in 163 and other mailboxes. it has been tested on 163 NetEase mailbox. it took a long time to explore it step by step, finally, the test was successful on 163 NetEase mailbox. I will share this process with you.

Let's take a look at the question first.The server address and port number of NetEase (163) mailbox:

I. preparations

When using NetEase mailbox, of course, you have to register an account. I don't need to talk about it. Register it myself...

After registration, you must enable the POP3/SMTP/IMAP service. When you enable the service, you need a client authorization password (mobile phone verification is required here, and the mobile phone number is required for MD ).

Step 1:

Step 2:


After confirmation, the following dialog box will pop up, and the authorization password will also be sent to your text message. remember to remember this authorization password.


After the service is enabled, if [name] is not set, the system will prompt you to set [name] before sending the email when writing the email. of course, you can also set it in advance ..


II. code

Download PHPMailer (put PHPMailer under the vender directory after the download, and there are a lot of unnecessary things in the file. let's take a look at it)

Careful students are in the class. phpmailer. php class. pop3.php class. smtp. the default port number is shown in the three php files. the default SMTP port number is 25, which is the same as the non-SSL protocol port number of the SMTP sending server under 163.

Html layout:

 
  Document 

Config. php configuration:

'Mail _ host' => 'smtp .163.com ', // smtp server name 'mail _ SMTPAUTH' => TRUE, // enable smtp Authentication 'mail _ username' => 'Zha ***** 22@163.com ', // The sender's mailbox name 'mail _ password' => 'olagbqsyeyhilcwu ', // 163 email sender authorization password 'mail _ from' => 'Zha *** 22@163.com ', // sender's email address 'mail _ fromname' => 'Snow in the sky', // sender's name 'mail _ charset' => 'utf-8 ', // Set the email encoding 'mail _ ISHTML '=> TRUE, // whether the email is in HTML format

Function. php public functions:

/** Send email * @ param $ to string * @ param $ title string * @ param $ content string * @ return bool **/function sendMail ($ to, $ title, $ content) {Vendor ('phpmailer. PHPMailerAutoload '); $ mail = new PHPMailer (); // instantiate $ mail-> IsSMTP (); // enable SMTP $ mail-> Host = C ('mail _ host'); // name of the smtp server (QQ mailbox is used as an example here) $ mail-> SMTPAuth = C ('mail _ SMTPAUTH '); // enable smtp Authentication $ MAIL-> Username = C ('mail _ username '); // sender's mailbox name $ mail-> Password = C ('mail _ password '); // 163 email sender authorization password $ mail-> From = C ('mail _ from'); // sender address (that is, your email address) $ mail-> FromName = C ('mail _ fromname'); // sender's name $ MAIL-> AddAddress ($ to, "Dear customer "); $ mail-> WordWrap = 50; // set the length of each line. $ mail-> IsHTML (C ('mail _ ISHTML ')); // whether the email is in HTML format $ mail-> CharSet = C ('mail _ charset'); // Set the email encoding $ MAIL-> Subject = $ title; // email subject $ mail-> Body = $ content; // email content $ mail-> AltBody = "this is a plain text Body on a non-profit HTML email client "; // the email body does not support alternate display of HTML return ($ mail-> Send ());}

Add method call:

Public function add () {if (SendMail (

After a long time, I tried it step by step and finally successfully tested it on 163 NetEase mailbox. I will share this process with you.

Let's take a look at the question first.The server address and port number of NetEase (163) mailbox:

I. preparations

When using NetEase mailbox, of course, you have to register an account. I don't need to talk about it. Register it myself...

After registration, you must enable the POP3/SMTP/IMAP service. When you enable the service, you need a client authorization password (mobile phone verification is required here, and the mobile phone number is required for MD ).

Step 1:

Step 2:


After confirmation, the following dialog box will pop up, and the authorization password will also be sent to your text message. remember to remember this authorization password.


After the service is enabled, if [name] is not set, the system will prompt you to set [name] before sending the email when writing the email. of course, you can also set it in advance ..


II. code

Download PHPMailer (put PHPMailer under the vender directory after the download, and there are a lot of unnecessary things in the file. let's take a look at it)

Careful students are in the class. phpmailer. php class. pop3.php class. smtp. the default port number is shown in the three php files. the default SMTP port number is 25, which is the same as the non-SSL protocol port number of the SMTP sending server under 163.

Html layout:

 
   Document 

Config. php configuration:

'Mail _ host' => 'smtp .163.com ', // smtp server name 'mail _ SMTPAUTH' => TRUE, // enable smtp Authentication 'mail _ username' => 'Zha ***** 22@163.com ', // The sender's mailbox name 'mail _ password' => 'olagbqsyeyhilcwu ', // 163 email sender authorization password 'mail _ from' => 'Zha *** 22@163.com ', // sender's email address 'mail _ fromname' => 'Snow in the sky', // sender's name 'mail _ charset' => 'utf-8 ', // Set the email encoding 'mail _ ISHTML '=> TRUE, // whether the email is in HTML format

Function. php public functions:

/** Send email * @ param $ to string * @ param $ title string * @ param $ content string * @ return bool **/function sendMail ($ to, $ title, $ content) {Vendor ('phpmailer. PHPMailerAutoload '); $ mail = new PHPMailer (); // instantiate $ mail-> IsSMTP (); // enable SMTP $ mail-> Host = C ('mail _ host'); // name of the smtp server (QQ mailbox is used as an example here) $ mail-> SMTPAuth = C ('mail _ SMTPAUTH '); // enable smtp Authentication $ MAIL-> Username = C ('mail _ username '); // sender's mailbox name $ mail-> Password = C ('mail _ password '); // 163 email sender authorization password $ mail-> From = C ('mail _ from'); // sender address (that is, your email address) $ mail-> FromName = C ('mail _ fromname'); // sender's name $ MAIL-> AddAddress ($ to, "Dear customer "); $ mail-> WordWrap = 50; // set the length of each line. $ mail-> IsHTML (C ('mail _ ISHTML ')); // whether the email is in HTML format $ mail-> CharSet = C ('mail _ charset'); // Set the email encoding $ MAIL-> Subject = $ title; // email subject $ mail-> Body = $ content; // email content $ mail-> AltBody = "this is a plain text Body on a non-profit HTML email client "; // the email body does not support alternate display of HTML return ($ mail-> Send ());}

Add method call:

___FCKpd___3

After the above work, the next access address, through the form to 163 (NetEase) mailbox to send an email (such as: send to the 123456@163.com), you can also send to yourself, after sending, the message is successfully sent. You can log on to your mailbox to view emails.

Send and receive emails via QQ mail

Address and Port of the QQ mail sending and receiving server

Preparation:
1. set an independent mailbox password
2. enable the POP3/SMTP service

Configuration:

'Mail _ host' => 'smtp .qq.com ', // smtp server name 'mail _ SMTPAUTH' => TRUE, // enable smtp Authentication 'mail _ username' => '2017 *** 34@qq.com ', // sender's mailbox name 'mail _ password' =>'s *** 1241 ', // qqmail sender independent password 'mail _ from' => '2017 *** 34@qq.com ', // sender address 'mail _ fromname' => 'login ', // sender name (qq mail nickname) 'mail _ charset' => 'utf-8', // Set the email encoding 'mail _ ISHTML '=> TRUE, // whether the email is in HTML format

You do not need to change the other items. after the change, you can not only send emails to QQ mail users, but also send emails to 163 mail users.

The above is thinkphp's method for sending and receiving emails through email 163 and other mailboxes. I hope it will be helpful for everyone's learning.

POST ['mail'],

After a long time, I tried it step by step and finally successfully tested it on 163 NetEase mailbox. I will share this process with you.

Let's take a look at the question first.The server address and port number of NetEase (163) mailbox:

I. preparations

When using NetEase mailbox, of course, you have to register an account. I don't need to talk about it. Register it myself...

After registration, you must enable the POP3/SMTP/IMAP service. When you enable the service, you need a client authorization password (mobile phone verification is required here, and the mobile phone number is required for MD ).

Step 1:

Step 2:


After confirmation, the following dialog box will pop up, and the authorization password will also be sent to your text message. remember to remember this authorization password.


After the service is enabled, if [name] is not set, the system will prompt you to set [name] before sending the email when writing the email. of course, you can also set it in advance ..


II. code

Download PHPMailer (put PHPMailer under the vender directory after the download, and there are a lot of unnecessary things in the file. let's take a look at it)

Careful students are in the class. phpmailer. php class. pop3.php class. smtp. the default port number is shown in the three php files. the default SMTP port number is 25, which is the same as the non-SSL protocol port number of the SMTP sending server under 163.

Html layout:

 
   Document 

Config. php configuration:

'Mail _ host' => 'smtp .163.com ', // smtp server name 'mail _ SMTPAUTH' => TRUE, // enable smtp Authentication 'mail _ username' => 'Zha ***** 22@163.com ', // The sender's mailbox name 'mail _ password' => 'olagbqsyeyhilcwu ', // 163 email sender authorization password 'mail _ from' => 'Zha *** 22@163.com ', // sender's email address 'mail _ fromname' => 'Snow in the sky', // sender's name 'mail _ charset' => 'utf-8 ', // Set the email encoding 'mail _ ISHTML '=> TRUE, // whether the email is in HTML format

Function. php public functions:

/** Send email * @ param $ to string * @ param $ title string * @ param $ content string * @ return bool **/function sendMail ($ to, $ title, $ content) {Vendor ('phpmailer. PHPMailerAutoload '); $ mail = new PHPMailer (); // instantiate $ mail-> IsSMTP (); // enable SMTP $ mail-> Host = C ('mail _ host'); // name of the smtp server (QQ mailbox is used as an example here) $ mail-> SMTPAuth = C ('mail _ SMTPAUTH '); // enable smtp Authentication $ MAIL-> Username = C ('mail _ username '); // sender's mailbox name $ mail-> Password = C ('mail _ password '); // 163 email sender authorization password $ mail-> From = C ('mail _ from'); // sender address (that is, your email address) $ mail-> FromName = C ('mail _ fromname'); // sender's name $ MAIL-> AddAddress ($ to, "Dear customer "); $ mail-> WordWrap = 50; // set the length of each line. $ mail-> IsHTML (C ('mail _ ISHTML ')); // whether the email is in HTML format $ mail-> CharSet = C ('mail _ charset'); // Set the email encoding $ MAIL-> Subject = $ title; // email subject $ mail-> Body = $ content; // email content $ mail-> AltBody = "this is a plain text Body on a non-profit HTML email client "; // the email body does not support alternate display of HTML return ($ mail-> Send ());}

Add method call:

___FCKpd___3

After the above work, the next access address, through the form to 163 (NetEase) mailbox to send an email (such as: send to the 123456@163.com), you can also send to yourself, after sending, the message is successfully sent. You can log on to your mailbox to view emails.

Send and receive emails via QQ mail

Address and Port of the QQ mail sending and receiving server

Preparation:
1. set an independent mailbox password
2. enable the POP3/SMTP service

Configuration:

___FCKpd___4

You do not need to change the other items. after the change, you can not only send emails to QQ mail users, but also send emails to 163 mail users.

The above is thinkphp's method for sending and receiving emails through email 163 and other mailboxes. I hope it will be helpful for everyone's learning.

POST ['title'],

After a long time, I tried it step by step and finally successfully tested it on 163 NetEase mailbox. I will share this process with you.

Let's take a look at the question first.The server address and port number of NetEase (163) mailbox:

I. preparations

When using NetEase mailbox, of course, you have to register an account. I don't need to talk about it. Register it myself...

After registration, you must enable the POP3/SMTP/IMAP service. When you enable the service, you need a client authorization password (mobile phone verification is required here, and the mobile phone number is required for MD ).

Step 1:

Step 2:


After confirmation, the following dialog box will pop up, and the authorization password will also be sent to your text message. remember to remember this authorization password.


After the service is enabled, if [name] is not set, the system will prompt you to set [name] before sending the email when writing the email. of course, you can also set it in advance ..


II. code

Download PHPMailer (put PHPMailer under the vender directory after the download, and there are a lot of unnecessary things in the file. let's take a look at it)

Careful students are in the class. phpmailer. php class. pop3.php class. smtp. the default port number is shown in the three php files. the default SMTP port number is 25, which is the same as the non-SSL protocol port number of the SMTP sending server under 163.

Html layout:

 
   Document 

Config. php configuration:

'Mail _ host' => 'smtp .163.com ', // smtp server name 'mail _ SMTPAUTH' => TRUE, // enable smtp Authentication 'mail _ username' => 'Zha ***** 22@163.com ', // The sender's mailbox name 'mail _ password' => 'olagbqsyeyhilcwu ', // 163 email sender authorization password 'mail _ from' => 'Zha *** 22@163.com ', // sender's email address 'mail _ fromname' => 'Snow in the sky', // sender's name 'mail _ charset' => 'utf-8 ', // Set the email encoding 'mail _ ISHTML '=> TRUE, // whether the email is in HTML format

Function. php public functions:

/** Send email * @ param $ to string * @ param $ title string * @ param $ content string * @ return bool **/function sendMail ($ to, $ title, $ content) {Vendor ('phpmailer. PHPMailerAutoload '); $ mail = new PHPMailer (); // instantiate $ mail-> IsSMTP (); // enable SMTP $ mail-> Host = C ('mail _ host'); // name of the smtp server (QQ mailbox is used as an example here) $ mail-> SMTPAuth = C ('mail _ SMTPAUTH '); // enable smtp Authentication $ MAIL-> Username = C ('mail _ username '); // sender's mailbox name $ mail-> Password = C ('mail _ password '); // 163 email sender authorization password $ mail-> From = C ('mail _ from'); // sender address (that is, your email address) $ mail-> FromName = C ('mail _ fromname'); // sender's name $ MAIL-> AddAddress ($ to, "Dear customer "); $ mail-> WordWrap = 50; // set the length of each line. $ mail-> IsHTML (C ('mail _ ISHTML ')); // whether the email is in HTML format $ mail-> CharSet = C ('mail _ charset'); // Set the email encoding $ MAIL-> Subject = $ title; // email subject $ mail-> Body = $ content; // email content $ mail-> AltBody = "this is a plain text Body on a non-profit HTML email client "; // the email body does not support alternate display of HTML return ($ mail-> Send ());}

Add method call:

___FCKpd___3

After the above work, the next access address, through the form to 163 (NetEase) mailbox to send an email (such as: send to the 123456@163.com), you can also send to yourself, after sending, the message is successfully sent. You can log on to your mailbox to view emails.

Send and receive emails via QQ mail

Address and Port of the QQ mail sending and receiving server

Preparation:
1. set an independent mailbox password
2. enable the POP3/SMTP service

Configuration:

___FCKpd___4

You do not need to change the other items. after the change, you can not only send emails to QQ mail users, but also send emails to 163 mail users.

The above is thinkphp's method for sending and receiving emails through email 163 and other mailboxes. I hope it will be helpful for everyone's learning.

POST ['content']) {$ this-> success ('sent successfully! ');} Else {$ this-> error ('sending failed ');}}

After the above work, the next access address, through the form to 163 (NetEase) mailbox to send an email (such as: send to the 123456@163.com), you can also send to yourself, after sending, the message is successfully sent. You can log on to your mailbox to view emails.

Send and receive emails via QQ mail

Address and Port of the QQ mail sending and receiving server

Preparation:
1. set an independent mailbox password
2. enable the POP3/SMTP service

Configuration:

___FCKpd___4

You do not need to change the other items. after the change, you can not only send emails to QQ mail users, but also send emails to 163 mail users.

The above is thinkphp's method for sending and receiving emails through email 163 and other mailboxes. I hope it will be helpful for everyone's learning.

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.