when I try to send an email using swiftmailer in my symfony project I get this exception,
here's my config.yml :
swiftmailer:
transport: '%mailer_transport%'
encryption: '%mailer_encryption%'
port: '%mailer_port%'
auth_mode: '%mailer_auth_mode%'
host: '%mailer_host%'
username: '%mailer_user%'
password: '%mailer_password%'
spool: { type: memory }
and my parameters.yml :
parameters:
database_host: 127.0.0.1
database_port: null
database_name: pidev
database_user: root
database_password: null
mailer_transport: smtp
mailer_encryption: ssl
mailer_auth_mode: login
mailer_port: 465
mailer_host: smtp.gmail.com
mailer_user: 'myGmailAddress'
mailer_password: 'mypassword'
secret: ThisTokenIsNotSoSecretChangeIt
I've allowed less secure apps on my gmail address and disabled my antivirus and my firewall. Also I've already tryed to ping smtp.gmail.com, it works fine but I got the same problem.
Any help please ?
答案 0 :(得分:0)
使用Gmail发送电子邮件非常简单。配置以下键:
swiftmailer:
transport: gmail
username: %mailer_user%
password: %mailer_password%
你完成了!
答案 1 :(得分:-1)
我已经解决了这个问题,我只想添加以下两个代码行:
$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;
in vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php
在第263行之后,所以它看起来像是:
$options = array_merge($options, $this->_params['stream_context_options']);
$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;
现在一切正常!