Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to send and receive 163or QQ email in thinkphp Framework

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "thinkphp framework how to achieve 163or QQ email sending and receiving", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "thinkphp framework how to achieve 163or QQ email sending and receiving" bar!

Before getting to the point, let's take a look at the server address and port number of NetEase's mailbox:

I. preliminary preparation

To use NetEase's mailbox, of course, you have to register an account. I don't need to say any more about this. I'll register myself.

After registering, you need to open the POP3/SMTP/IMAP service. When starting the service, the client authorization password is required (mobile phone verification is required here, and MD asks for the mobile phone number in a roundabout way).

Step 1:

Step 2:

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

After the service is enabled, if [name] is not set, you will be prompted to set [name] before you can send email. Of course, you can also set it up in advance.

Second, the code part

PHPMailer download (put the PHPMailer in the Vendor directory after download, and there are a lot of unnecessary things in the file, so watch and deal with it.)

Careful students take a look at the default port number in the three files of class.phpmailer.php class.pop3.php class.smtp.php. The default port number of SMTP is the same as the non-SSL protocol port number of the SMTP sending server under 163s.

Html layout:

Document recipient mailbox: title: content

Config.php configuration:

'MAIL_HOST' = >' name of the smtp.163.com',//smtp server 'MAIL_SMTPAUTH' = > TRUE, / / enable smtp authentication' MAIL_USERNAME' = > 'zha****22@163.com',// sender's mailbox name' MAIL_PASSWORD' = > 'olagbqsyeyhilcwu',//163 mailbox sender authorization password' MAIL_FROM' = > 'zha****22@163.com',// sender's email address' MAIL_FROMNAME'= > 'the sky is still snowing' / / Sender name 'MAIL_CHARSET' = >' utf-8',// set message Code 'MAIL_ISHTML' = > TRUE, / / whether the message 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 smtp server (take QQ Mail as an example) $mail- > SMTPAuth = C ('MAIL_SMTPAUTH') / / enable smtp authentication $mail- > Username = C ('MAIL_USERNAME'); / / Sender email name $mail- > Password = C (' MAIL_PASSWORD'); / / Sender Authorization password $mail- > From = C ('MAIL_FROM'); / / Sender address (i.e. your email address) $mail- > FromName = C (' MAIL_FROMNAME'); / / Sender name $mail- > AddAddress ($to, "distinguished customer"); $mail- > WordWrap = 50 / / set per line character length $mail- > IsHTML (C ('MAIL_ISHTML')); / / whether or not HTML format email $mail- > CharSet=C (' MAIL_CHARSET'); / / set email encoding $mail- > Subject = $title; / / email subject $mail- > Body = $content; / / email content $mail- > AltBody = "this is a plain text body in a non-profit HTML email client" / / message body does not support alternate display return of HTML ($mail- > Send ());}

The add method call:

Public function add () {if (SendMail ($_ POST ['mail'], $_ POST [' title'], $_ POST ['content'])) {$this- > success (' sent successfully!') ;} else {$this- > error ('send failed');}}

After you have finished the above work, visit the address and send an email to NetEase (e. G. to 123456@163.com) through the form, or you can send it to yourself. After sending, you will see that it has been sent successfully. Next, you can log in to your mailbox to check your email.

QQ Mail receives and sends emails

QQ Mail transceiver server address and port

Prepare:

1. Set a separate mailbox password

2. Enable POP3/SMTP service

Configuration:

The name of 'MAIL_HOST' = >' smtp.qq.com',//smtp server 'MAIL_SMTPAUTH' = > TRUE, / / enable smtp authentication' MAIL_USERNAME' = > '541 email address / sender email name' MAIL_PASSWORD' = >'s email address' MAIL_FROMNAME'= > 'sender's unique password for QQ mailbox' MAIL_FROM' = > 541 email address / sender address' MAIL_FROMNAME'= > 'prison love' / / Sender name (QQ Mail nickname) 'MAIL_CHARSET' = >' utf-8',// set email Code 'MAIL_ISHTML' = > TRUE, / / whether the email is in HTML format

Others do not need to be changed. After completion, you can send mail not only to QQ Mail users, but also to 163mailbox users.

Thank you for your reading, the above is the content of "thinkphp Framework how to send and receive 163or QQ email". After the study of this article, I believe you have a deeper understanding of how thinkphp Framework can send and receive 163or QQ email, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report