In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "TP how to cooperate with phpmailer to achieve email function", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how TP cooperates with phpmailer to achieve the function of sending email.
TP cooperates with phpmailer email function
Find phpmailer in https://packagist.org
Use composer to download phpmailer into the project
Composer require phpmailer/phpmailer
Configure the phpmailer code
/ / Import the PHPMailer class into the global namespace / / these must be at the top of the script, not the autoloader function send_email ($to,$subject='',$content='') of use PHPMailer\ PHPMailer\ PHPMailer;use PHPMailer\ PHPMailer\ Exception;// Load Composer inside the function {/ / instantiating and passing `true` enables the exception $mail = new PHPMailer (true); / / the server sets try {/ / Server settings $mail- > SMTPDebug = 2 / / enable detailed debug output 2 detailed 1 simple 0 does not display $mail- > isSMTP (); / / use SMTP $mail- > Host = 'smtp.qq.com'; / / set the SMTP server through $mail- > SMTPAuth = true / / enable SMTP authentication $mail- > Username = '1758604817 authentication qq.compose; / / SMTP username $mail- > Password =' uzbslzhwjbjqejic'; / / authorization code for mailbox, not mailbox password $mail- > SMTPSecure = 'ssl'; / / enable TLS encryption `The PHPMailer:: ENCRYPTION_ SMTPS` encourages $mail- > Port = 465; / / the TCP port to be connected. For the above `PHPMailer:: ENCRYPTION_ SMTPS`, use 465 / / recipient $mail- > setFrom ('1758604817roomqq.compose,' pigment'); $mail- > addAddress ($to) / / add recipient / / $mail- > addAddress ('ellen@example.com'); / / name is optional / / $mail- > addReplyTo (' info@example.com', 'Information'); / / $mail- > addCC (' cc@example.com'); / / $mail- > addBCC ('bcc@example.com') / / attachment / / $mail- > addAttachment ('/ var/tmp/file.tar.gz'); / / add attachment / / $mail- > addAttachment ('/ tmp/image.jpg', 'new.jpg'); / / optional name / / content $mail- > isHTML (true) / / set the email format to HTML $mail- > Subject = $subject; $mail- > Body = $content; return $mail- > send ();} catch (Exception $e) {return $mail- > ErrorInfo;}}
Add the method to application's common file and encapsulate it into a method so that it can be called anywhere
Matters needing attention
Attention items learn to troubleshoot in debug
Database link question whether there is an error in the table name
It is important that mailbox authorization code and mailbox password are not the same thing.
At this point, I believe you have a deeper understanding of "TP how to cooperate with phpmailer to achieve e-mail function". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.