使用 swiftmailer 在 symfony 2 中通过 smtp.gmail.com 发送邮件 [英] Send mail through smtp.gmail.com in symfony 2 using swiftmailer

查看:37
本文介绍了使用 swiftmailer 在 symfony 2 中通过 smtp.gmail.com 发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 gmail 从 xampp localhost 发送邮件时遇到问题.经过很长时间,我终于成功了.我正在与大家分享它.如果我错了,需要适当的解决方案.

I am having a trouble of sending mail from xampp localhost using gmail. And after a long time I finally successful on it. And I am sharing it with all you. If I am wrong need proper solution for it.

在你的 symfony 2 的 config.yml 中写这些

in config.yml of your symfony 2 Write those

swiftmailer:
    disable_delivery:  false
    transport: %mailer_transport%
    host:      %mailer_host%
    username:  %mailer_user%
    password:  %mailer_password%
    port:      %mailer_port%
    encryption: %mailer_encryption%

在你的参数.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 

推荐答案

你可以试试这个

Parameter.yml

mailer_transport: gmail
mailer_encryption: ssl
mailer_auth_mode: login
mailer_host: smtp.gmail.com
mailer_user: 'xxxxxxxxxxxx'

config.yml

swiftmailer:
   transport: gmail
   host:      smtp.gmail.com
   username:  'Yourmail@gmail.com'
   password:  'Password'

这篇关于使用 swiftmailer 在 symfony 2 中通过 smtp.gmail.com 发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆