多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
如果在Gmail上进行接收email,需要开启“低安全性应用程式存取权”,链接: https://myaccount.google.com/u/0/lesssecureapps?rfn=27&rfnc=1&eid=-8682605152577733367&et=1&asae=2&anexp=gpsv2-control&pli=1 如图: <img class="alignnone size-medium" src="http://yuan.network/wp-content/uploads/2018/08/20180819225808.png" alt="" width="100%" /> Laravel 8 gmail配置,.env: ``` MAIL_MAILER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=587 MAIL_USERNAME=neo365test@gmail.com MAIL_PASSWORD=your_password MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS=neo365test@gmail.com MAIL_FROM_NAME="${APP_NAME}" ``` qq email配置,.env: ``` MAIL_MAILER=smtp MAIL_HOST=smtp.qq.com MAIL_PORT=465 MAIL_USERNAME=1619319967@qq.com MAIL_PASSWORD=your_password MAIL_ENCRYPTION=ssl MAIL_FROM_ADDRESS=1619319967@qq.com MAIL_FROM_NAME="${APP_NAME}" ``` MailController.php: ``` <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Mail; class MailController extends Controller { public function send() { $data = array('name'=>"Email 1", "body" => "Test mail"); // email標記 Mail::send('emails.index', $data, function($message) { $message->to('neo365test@gmail.com', 'Neo get email')->subject('Email title'); // 收件者 $message->from('neo365test@gmail.com','Neo sent email'); // 寄件者 }); echo 'Send email OK !'; } } ``` resources/views/emails/index.blade.php: ``` Send email is working ! ``` 源码: 链接:https://pan.baidu.com/s/1qw84WaNtcTU9oVzYKDrxZA 密码:uggp Laravel 8发送email源码: 链接:https://pan.baidu.com/s/1b8mBqS1Ccp8OGNW3f_ExSw 提取码:1n6n