• <tfoot id='KZD5K'></tfoot>

    <legend id='KZD5K'><style id='KZD5K'><dir id='KZD5K'><q id='KZD5K'></q></dir></style></legend>

    <small id='KZD5K'></small><noframes id='KZD5K'>

    • <bdo id='KZD5K'></bdo><ul id='KZD5K'></ul>

    1. <i id='KZD5K'><tr id='KZD5K'><dt id='KZD5K'><q id='KZD5K'><span id='KZD5K'><b id='KZD5K'><form id='KZD5K'><ins id='KZD5K'></ins><ul id='KZD5K'></ul><sub id='KZD5K'></sub></form><legend id='KZD5K'></legend><bdo id='KZD5K'><pre id='KZD5K'><center id='KZD5K'></center></pre></bdo></b><th id='KZD5K'></th></span></q></dt></tr></i><div id='KZD5K'><tfoot id='KZD5K'></tfoot><dl id='KZD5K'><fieldset id='KZD5K'></fieldset></dl></div>

      1. 如何在 Yii2 中使用 swiftMailer

        How to use the swiftMailer in Yii2(如何在 Yii2 中使用 swiftMailer)

        1. <small id='tLeRi'></small><noframes id='tLeRi'>

              <legend id='tLeRi'><style id='tLeRi'><dir id='tLeRi'><q id='tLeRi'></q></dir></style></legend><tfoot id='tLeRi'></tfoot>

                <i id='tLeRi'><tr id='tLeRi'><dt id='tLeRi'><q id='tLeRi'><span id='tLeRi'><b id='tLeRi'><form id='tLeRi'><ins id='tLeRi'></ins><ul id='tLeRi'></ul><sub id='tLeRi'></sub></form><legend id='tLeRi'></legend><bdo id='tLeRi'><pre id='tLeRi'><center id='tLeRi'></center></pre></bdo></b><th id='tLeRi'></th></span></q></dt></tr></i><div id='tLeRi'><tfoot id='tLeRi'></tfoot><dl id='tLeRi'><fieldset id='tLeRi'></fieldset></dl></div>
                  <tbody id='tLeRi'></tbody>
                • <bdo id='tLeRi'></bdo><ul id='tLeRi'></ul>

                  本文介绍了如何在 Yii2 中使用 swiftMailer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我终于无法理解如何在 Yii2 中使用 swiftMailer 扩展.就这个题目来看,我没有发现问题,任务是微不足道的,但到最后我还是看不懂.

                  I can't finally understand how to use the swiftMailer extension in Yii2. Judging by that on this subject I didn't find questions, the task is trivial, but up to the end I couldn't understand.

                  有些例子没有更详细地描述发送信件的所有周期,或者我不明白一些事情:(

                  There are examples which don't describe in more detail all cycle of sending the letter or I don't understand something :(

                  设置

                      return [
                      //....
                     'components' => [
                      ......
                      'mail' => [
                        'class' => 'yiiswiftmailerMailer',
                        'transport' => [
                          'class' => 'Swift_SmtpTransport',
                          'host' => 'localhost',
                          'username' => 'username',
                          'password' => 'password',
                          'port' => '587',
                          'encryption' => 'tls',
                        ],
                      ],
                    ]
                  ];
                  

                  发送

                  Yii::$app->mail->compose()
                  ->setTo($toEmail)
                  ->setFrom([$this->email => $this->name])
                  ->setSubject($this->subject)
                  ->setTextBody($this->body)
                  ->send();
                  

                  我希望收到一个具体的工作示例.谢谢.

                  附言我调整了域记录 MX、DKIM、SPF 添加.

                  P.S. I adjusted domain records MX, DKIM, SPF added.

                  UPD(一些答案):

                  在发件人"字段中传递的电子邮件,在该字段中默认放下的返回路径",必须是现有地址.一些供应商没有允许从不存在的电子邮件地址发送邮件.

                  E-mail which is passed in "From" field, it is put down by default in the field of "Return-path", has to be the existing address. Some providers don't allow sending mail from nonexistent email addresses.

                  推荐答案

                  确保您已在生产环境中初始化您的应用程序以从您的应用程序发送电子邮件,否则它将被写入邮件输出文件夹.或手动编辑配置文件如下.

                  Make sure you have initialised your application in production environment to send emails from your application,else it will be written in to the mailoutput folder.Or manually edit the config file like follows.

                  在你的 common/main-local.php 的组件部分

                  In the components's section of your common/main-local.php

                  'mail' => [
                          'class' => 'yiiswiftmailerMailer',
                          'viewPath' => '@backend/mail',
                          'useFileTransport' => false,//set this property to false to send mails to real email addresses
                          //comment the following array to send mail using php's mail function
                          'transport' => [
                              'class' => 'Swift_SmtpTransport',
                              'host' => 'smtp.gmail.com',
                              'username' => 'username@gmail.com',
                              'password' => 'password',
                              'port' => '587',
                              'encryption' => 'tls',
                              ],
                      ],
                  

                  在你的控制器中

                      Yii::$app->mail->compose('your_view', ['params' => $params])
                      ->setFrom([Yii::$app->params['supportEmail'] => 'Test Mail'])
                      ->setTo('to_email@xx.com')
                      ->setSubject('This is a test mail ' )
                      ->send();
                  

                  这应该有效!希望能帮到你!

                  This should work! Hope this will help you!

                  这篇关于如何在 Yii2 中使用 swiftMailer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                    <tfoot id='omPbr'></tfoot>

                    <small id='omPbr'></small><noframes id='omPbr'>

                    • <legend id='omPbr'><style id='omPbr'><dir id='omPbr'><q id='omPbr'></q></dir></style></legend>
                        <tbody id='omPbr'></tbody>
                        <bdo id='omPbr'></bdo><ul id='omPbr'></ul>

                        <i id='omPbr'><tr id='omPbr'><dt id='omPbr'><q id='omPbr'><span id='omPbr'><b id='omPbr'><form id='omPbr'><ins id='omPbr'></ins><ul id='omPbr'></ul><sub id='omPbr'></sub></form><legend id='omPbr'></legend><bdo id='omPbr'><pre id='omPbr'><center id='omPbr'></center></pre></bdo></b><th id='omPbr'></th></span></q></dt></tr></i><div id='omPbr'><tfoot id='omPbr'></tfoot><dl id='omPbr'><fieldset id='omPbr'></fieldset></dl></div>