发邮件怎么配置 [ 2.0 版本 ]
'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' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'pop.163.com',
'username' => '13180882389@163.com',
'password' => 'f1993XXX',
'port' => '995',
'encryption' => 'ssl',
],
'messageConfig' => [
'charset' => 'UTF-8',
'from' => ['13180882389@163.com'=>'admin']
],
报错提醒:
Expected response code 220 but got code "", with message "+OK Welcome to coremail Mail Pop3 Server (163coms[726cd87d72d896a1ac393507346040fas])
请问怎么配置才能成功发邮件?
共 2 个回答
-
host换成 smtp.163.com试一下,不行的话你参考下教程 yii2发送邮件教程试试看
共 1 条回复 -
不一定是
配置
的问题,swiftmailer
很久没有更新了。确认一下是不是下面的原因:由于php5.6、php7对完全有所加强,所以导致swiftmailer库出‘Bug’:
请打开文件vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php,找到_establishSocketConnection()
,对$options做些修改,修改后的代码片段为:258 } 259 $options = array(); 260 $options['ssl']['allow_self_signed'] = false; 261 $options['ssl']['verify_peer'] = false; 262 $options['ssl']['verify_peer_name'] = false; 263 if (!empty($this->_params['sourceIp'])) { 264 $options['socket']['bindto'] = $this->_params['sourceIp'].':0'; 265 }
其中
260, 261, 262
为添加的语句。共 1 条回复
fanfan
注册时间:2016-04-27
最后登录:2016-06-01
在线时长:1小时11分
最后登录:2016-06-01
在线时长:1小时11分
- 粉丝1
- 金钱45
- 威望0
- 积分55