使用swiftmailer通过symfony 2中的smtp.gmail.com发送邮件

Al-*_*han 5 xampp swiftmailer symfony

我在使用gmail从xampp localhost发送邮件时遇到了麻烦.经过很长一段时间我终于成功了.我和你们分享.如果我错了需要适当的解决方案.

在你的symfony 2的config.yml中写下那些

swiftmailer:
    disable_delivery:  false
    transport: %mailer_transport%
    host:      %mailer_host%
    username:  %mailer_user%
    password:  %mailer_password%
    port:      %mailer_port%
    encryption: %mailer_encryption%
Run Code Online (Sandbox Code Playgroud)

在你的parameters.yml中

mailer_transport: smtp
mailer_host: smtp.gmail.com
mailer_user: gmail_user_id_without_@gmail.com
mailer_password: Your_gmail_pass
mailer_port: 465 or 587
mailer_encryption:  ssl 
Run Code Online (Sandbox Code Playgroud)

GOP*_*OPI 6

你可以尝试这个

Parameter.yml

mailer_transport: gmail
mailer_encryption: ssl
mailer_auth_mode: login
mailer_host: smtp.gmail.com
mailer_user: 'xxxxxxxxxxxx'
Run Code Online (Sandbox Code Playgroud)

config.yml

swiftmailer:
   transport: gmail
   host:      smtp.gmail.com
   username:  'Yourmail@gmail.com'
   password:  'Password'
Run Code Online (Sandbox Code Playgroud)