您的位置:首页 > 编程语言 > PHP开发

在Laravel框架里实现邮箱验证---发送邮件

2020-02-13 04:05 288 查看

在.env文件下

 1.配置Laravel文件

     MAIL_DRIVER=smtp  //建议使用smtp方式

     MAIL_HOST=smtp.163.com  //建议使用163邮箱 QQ邮箱会有报错

     MAIL_PORT=25        //smtp 默认为25   

     MAIL_USERNAME=null   //自己的163帐号

     MAIL_PASSWORD=null //客户端密码

     MAIL_ENCRYPTION=null

2.修改config/email.php文件中的 

            'from' => ['address' => null, 'name' => null],   //手册上未提示,但实际应用中  如果为addredd=>null则报错,需要天写自己的163地址

3. 注册163的邮箱并进行邮箱帐号设置  POP3/SMTP/IMAP都要开启   并开启授权码并进行手机验证

4.参照Laravel手册里的邮件发送

                必须注意的是  在控制器引用邮件发送时  必须首先引用use  Mail

    ​    ​    ​    ​发送邮件测试

    ​    ​    ​    ​在路由里设置 

      

    ​    ​    ​    ​在控制器中写入方法

  ​其中

    ​    ​    ​    ​    ​    ​    ​    ​    ​    ​    ​    ​    ​1:Mail::raw  是发送原生数据,其他的内容发送方式在手册里都有提供;

    ​    ​    ​    ​    ​    ​    ​    ​    ​    ​    ​    ​    ​2.$message->subjuet('');是文件的标题

    ​    ​    ​    ​    ​    ​    ​    ​    ​    ​    ​    ​    ​3.$message->to();发送给谁

    ​    ​    ​

这是一份在 

$message
 消息生成器实例中可以使用的方法清单:

$message->from($address, $name = null);
$message->sender($address, $name = null);
$message->to($address, $name = null);
$message->cc($address, $name = null);
$message->bcc($address, $name = null);
$message->replyTo($address, $name = null);
$message->subject($subject);
$message->priority($level);
$message->attach($pathToFile, array $options = []);

// 以原始 $data 字符串附加一个文件...
$message->attachData($data, $name, array $options = []);

// 获取底层的 SwiftMailer 消息实例...
$message->getSwiftMessage();

转载于:https://my.oschina.net/majorD/blog/732712

  • 点赞
  • 收藏
  • 分享
  • 文章举报
chengjia3602 发布了0 篇原创文章 · 获赞 0 · 访问量 321 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: