fastadmin 发送邮件

1.配置文件

  'mail_type' => '1',
  'mail_smtp_host' => 'smtp.163.com',
  'mail_smtp_port' => '465',
  'mail_smtp_user' => '用户名',
  'mail_smtp_pass' => '',
  'mail_verify_type' => '2',
  'mail_from' => '15112345678@163.com',

2.控制器

 

use app\common\library\Email;
public function test()
{
    $email = new Email();
    $res=$email->
        subject('这里是邮件标题')->
        to('123456@qq.com')->
        message('这里是邮件正文')->
        send();
    if($res!==false){
        $this->success('返回成功');
    }else{
        $this->error('返回失败',$email->getError());
    }
}
posted @ 2020-07-12 10:57  CanyingV  阅读(863)  评论(0编辑  收藏  举报