通过Gmail SwiftMailer Symfony2发送电子邮件

时间:2015-10-14 19:09:48

标签: symfony swiftmailer

我试图通过commande用swiftmailer发送电子邮件但是我收到了此错误消息 指挥官:

php app/console swiftmailer:email:send

错误:

Connection could not be established with host smtp.gmail.com

为什么会这样? 我的配置parameters.yml文件如下所示:

parameters:
    database_host: 127.0.0.1
    database_port: null
    database_name: symfony
    database_user: root
    database_password: null
    mailer_transport: gmail
    mailer_host: smtp.gmail.com
    mailer_user: my gmail
    mailer_password: my password
    secret: secret

2 个答案:

答案 0 :(得分:0)

你可以试试这个:

#app/config/parameters.yml

parameters:
# ...
     mailer_transport: gmail
     mailer_host:      ~
     mailer_user:      your_gmail_username
     mailer_password:  your_gmail_password

答案 1 :(得分:0)

配置你的SwiftMailer(config.yml):

swiftmailer:
      transport: %mailer_transport%
      encryption: ssl
      host:      %mailer_host%
      username:  %mailer_user%
      password:  %mailer_password%
      spool:     { type: memory }