zoukankan      html  css  js  c++  java
  • yii2邮箱发送

    yii2 邮件发送  163邮箱

    1.在配置文件main-local.php components=>[]里面配置

    'mailer' => [
    'class' => 'yiiswiftmailerMailer',
    // send all mails to a file by default. You have to set
    // 'useFileTransport' to false and configure a transport
    // for the mailer to send real emails.
    'useFileTransport' => false,
    'transport' => [
    'class' => 'Swift_SmtpTransport',
    'host' => 'smtp.163.com', //每种邮箱的host配置不一样
    'username' => '18310496083@163.com',
    'password' => '774330595a',
    'port' => '25',
    'encryption' => 'tls',
    ],

    'messageConfig'=>[
    'charset'=>'UTF-8',
    'from'=>['18310496083@163.com'=>'shanzezhao']
    ],
    ],

    2.controller控制器中 代码:

    <?php $mail= Yii::$app->mailer->compose();

    $mail->setTo('***********@qq.com');

    $mail->setSubject("邮件测试");

    //$mail->setTextBody('zheshisha ');

    //发布纯文字文本 $mail->setHtmlBody("<br>问我我我我我");

    //发布可以带html标签的文本

    if($mail->send()) echo "success"; else echo "failse"; die(); ?>

    但愿对您有帮助哦!亲

  • 相关阅读:
    elementUI form select验证问题
    Echart--基本属性
    Echart--饼状图
    Echart--折线图
    Echart--多个柱形图
    Echart--单个柱形图
    Echart--圆型图
    构析函数和构造函数
    心情
    图片
  • 原文地址:https://www.cnblogs.com/yx520zhao/p/6603437.html
Copyright © 2011-2022 走看看