在阿里云Ecs上发送邮件功能,代码本地测试都ok,在生产环境报错
Connection could not be established with host
这是由于阿里的ecs服务器禁用了25
端口,切换成465/994
,就可以了。
后面产生了另外一个报错
Expected response code 220 but got code "", with message ""
正确的配置
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'useFileTransport' =>false,
'viewPath' => '@common/mail',
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => '',
'username' => '',
'password' => '',
'port' => '465/994',
'encryption' => 'ssl',
],
'messageConfig'=>[
'charset'=>'UTF-8',
'from'=>['notice@bdelay.com'=>'Bdelay']
],
],