laravel5.4 how to send mail using 163 mailbox

Source: Internet
Author: User
Tags how to send mail
E-mail is our daily development is essential to meet a demand, the following this article mainly introduces you about the laravel5.4 use 163 mailbox to send mail steps, the text through the sample code and pictures introduced in very detailed, the need for friends can refer to.

Objective

In fact, send the mailbox is not difficult, rather simple, this article will be introduced in detail about laravel5.4 with 163 e-mail messages related content, share out for everyone to reference the study, the following words do not say, come together to see the detailed introduction bar.

First, or now 163 to register an account and set up such as


Authorization code is very important, please remember, will be in Laravel. Env to be configured in the ~ ~

Second, if you have finished the above, then the next is the configuration. Env.


Mail_driver=smtpmail_host=smtp.163.commail_port=465mail_username= your account @163.commail_password= your client authorization password mail_from_ Address= your account @163.commail_from_name= account name Mail_encryption=ssl

Third, then the next step is to configure the route and write the message on the controller method.


Route::get (' mail/send ', ' commoncontroller@send ');

Feel free to write this send method on which controller:


public function Send () {$name = ' College June '; $flag = Mail::raw (' Hello, I'm a PHP program! ', function ($message) {$to = ' your QQ mailbox @qq.com '; $message->to ($to)->subject (' Plain text messaging test ');}); if (! $flag) {echo ' sent the message successfully, please check! ';} Else{echo ' failed to send mail, please try again! ';} The above is plain text, below is the accompanying file send//$flag = Mail::send (' emails.test ', [' name ' = ' + ' $name],function ($message) {//$to = ' Your QQ mailbox @qq.com ';//$message->to ($to)->subject (' text ');///$filePath = ' storage/exports/'. Iconv (' UTF-8 ', ' GBK ', ' student grades '). XLS ';//$attachment = Storage_path (' app/files/test.txt ');/////////Upload attachments//$message->attach ($attachment, [' as ' =] ' Text.txt ');//});//The following is a picture of the sent message//$imgPath = ' http://laravelacademy.org/wp-statics/images/carousel/ Laravelacademy.jpg ';//$flag = Mail::send (' emails.test ', [' name ' = = $name, ' imgpath ' = = $imgPath],function ($ Message) {//$to = ' Your QQ mailbox @qq.com ';//$message->to ($to)->subject (' Network picture Test ');//if (! $flag) {//echo ' Send mail Success, please check! ';//}else{//Echo ' failed to send mail, please try again! ';//  }}

Okay, so then you can get your own access to the route and you'll have the results you want ~~~~~

PS: The focus is to fix the error process, basically follow the steps to walk is probably not a big problem, but, The most important thing is that I use the Ubuntu16.04 system to do, the permissions within the problem should be the first priority to solve, so I recommend the first to give good permissions, in your directory Open command line:sudo chmod 777 -R ./

OK, next is to deal with the connection is not on the 163 netease mailbox problem, I can give the method is to add two lines of code in the streambuffer.php 263 lines:


$options [' SSL '] [' verify_peer '] = false; $options [' SSL '] [' verify_peer_name '] = false;

Basically follow the above steps can be done.

Summarize

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.