【问题标题】:Send email from other smtp in yii2从 yii2 中的其他 smtp 发送电子邮件
【发布时间】:2016-06-06 16:43:18
【问题描述】:

我使用 swiftmailer 从 yii2 发送电子邮件。我从网站获取代码,但其中大多数从 gmail.com 发送电子邮件。我想从我的大学电子邮件发送电子邮件,但它不起作用。有什么问题。这是代码:

在 main-local.php 中

'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@common/mail',
            // 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' => /*true*/false,
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.students.del.ac.id',
                'username' => 'if414024@students.del.ac.id',
                'password' => 'bmelar28',
                'port' => '587',
                'encryption' => 'tls',
            ],
],

【问题讨论】:

  • 尝试删除主机中的smtp,例如'host' => 'students.del.ac.id'

标签: yii2 swiftmailer


【解决方案1】:

删除'host' => students.del.ac.id中的smtp

显示以下代码

'mailer' => [
        'class' => 'yii\swiftmailer\Mailer',
        'viewPath' => '@common/mail',
        'useFileTransport' => false,
        'transport' => [
            'class' => 'Swift_SmtpTransport',
            'host' => 'students.del.ac.id',
            'username' => 'if414024@students.del.ac.id',
            'password' => 'bmelar28',
            'port' => '587',
            'encryption' => 'tls',                               
        ]
]

【讨论】:

  • 成功了。但是,如果我使用用户名:paket@del.ac.id 怎么办?我使用主机:del.ac.id 但我无法发送电子邮件。
  • 我收到此错误:预期响应代码为 220,但收到代码“421”,消息为“421 无法连接到 SMTP 服务器 172.21.2.30 (172.21.2.30:25),连接错误 10060”跨度>
【解决方案2】:

试试这个:更改端口号和主机

'mailer' => [
                'class' => 'yii\swiftmailer\Mailer',
                'viewPath' => '@common/mail',
                // 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' => /*true*/false,
                'transport' => [
                    'class' => 'Swift_SmtpTransport',
                    'host' => 'students.del.ac.id',
                    'username' => 'if414024@students.del.ac.id',
                    'password' => 'bmelar28',
                    'port' => '25',
                    'encryption' => 'tls',
                ],
    ],

【讨论】:

  • 如果我使用这个:paket@del.ac.id 和主机:del.ac.id 怎么办?我收到此错误:预期响应代码 220,但收到代码“421”,消息“421 无法连接到 SMTP 服务器 172.21.2.30 (172.21.2.30:25),连接错误 10060”
  • 通过更改 'port' => '25' 尝试一次
猜你喜欢
  • 1970-01-01
  • 2011-07-30
  • 2012-06-23
  • 2017-02-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-16
  • 2016-09-02
相关资源
最近更新 更多