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 does laravel5.4 use 163mailbox to send email?

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "laravel5.4 how to use 163mailbox to send email", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's train of thought slowly in depth, together to study and learn "laravel5.4 how to use 163mailbox to send email" bar!

First of all, it is now 163 to register an account and set it up as shown below.

The authorization code is very important, please remember that it will be configured in the .env of laravel later.

Second, if you have done all the above, then it is time to configure .env.

MAIL_DRIVER=smtpMAIL_HOST=smtp.163.comMAIL_PORT=465MAIL_USERNAME= your account @ 163.com MAILLINPASSWORD = your client authorization password MAIL_FROM_ADDRESS= your account @ 163.com MAILLINFROMNAME = account name MAIL_ENCRYPTION=ssl

The next step is to configure routing and write a way to send mail on the controller.

Route::get ('mail/send','CommonController@send')

Write this send method on any controller you want:

Public function send () {$name=' College Mr.'; $flag= Mail::raw ('Hello, I'm the PHP program!' , function ($message) {$to=' your QQ Mail @ qq.com';$message- > to ($to)-> subject ('text message test');}); if (! $flag) {echo 'email sent successfully, please check!' ;} else {echo 'failed to send mail, please try again!' ;} / / above is plain text, the following is the attached file sent / / $flag = Mail::send ('emails.test', [' name'= > $name], function ($message) {/ / $to = 'your QQ Mail @ qq.com';// $message- > to ($to)-> subject (' text'); / / $filePath = 'storage/exports/'.iconv (' UTF-8', 'GBK',' student grades'). / / $attachment = storage_path ('app/files/test.txt'); / / upload attachment / / $message- > attach in the email ($attachment, [' as'= > 'text.txt']); / /}); / / the following is the / / $imgPath =' http://laravelacademy.org/wp-statics/images/carousel/LaravelAcademy.jpg'; 'attached to the email / / $flag = Mail::send ('emails.test', [' name'= > $name,'imgPath'= > $imgPath], function ($message) {/ / $to = 'your QQ Mail @ qq.com';// $message-> to ($to)-> subject (' network photo test'); / / if (! $flag) {/ / echo 'email sent successfully, please check!' ; / /} else {/ / echo 'failed to send mail, please try again!' ; / /}}

OK, the next step is for you to access the route and get the results you want.

PS: the key point is to get rid of the error reporting process. Basically, following the steps will probably not be a big problem. However, the most important thing is that I use the Ubuntu16.04 system to do it, and the permission problem in it should be solved first, so I suggest that you first give permission and open the command line in your directory: sudo chmod 777-R. /

All right, the next step is to deal with the problem of not being able to connect to NetEase's mailbox. What I can do is to add two lines of code to line 263 of StreamBuffer.php:

Options ['ssl'] [' verify_peer'] = FALSE;$options ['ssl'] [' verify_peer_name'] = FALSE; thank you for reading, this is the content of "how laravel5.4 uses 163mailbox to send email". After the study of this article, I believe you have a deeper understanding of how laravel5.4 uses 163mailbox to send 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