dongnaopa6200 2015-07-17 11:35
浏览 44

在symfony中发送swiftmailer的电子邮件

I am devolping the application in symfony.I have use the swiftmailer for sending emails.But the mail is not recieved. I dont know where I wrong. Here is my code:

$message = \Swift_Message::newInstance()
                    ->setSubject('Password Reset')
                    ->setFrom('support@bwcmultimedia.com')
                    ->setTo('karank@ocodewire.com')
                    ->setBody($this->renderView('DRPRegistrarGeneralBundle:Email:k.txt.twig'));
                $mailStatus = $this->get('mailer')->send($message);

I have set the parameters.yml file:

 database_driver: pdo_mysql
    database_host: 127.0.0.1
    database_port: null
    database_name: database
    database_user: user
    database_password: pass
    mailer_transport: smtp
    mailer_encryption: 
    mailer_auth_mode: "login"
    mailer_host: smtp.gmail.com
    mailer_port: 25
    mailer_user: karansofat89@gmail.com
    mailer_password: pass
    locale: en
    secret: ThisTokenIsNotSoSecretChangeIt

Config file:

swiftmailer:
    transport: %mailer_transport%
    encryption: tls
    auth_mode: login
    host:      %mailer_host%
    username:  %mailer_user%
    password:  %mailer_password%

Please help

  • 写回答

1条回答 默认 最新

  • doumo0206 2015-07-17 11:51
    关注

    For sending emails through gmail, you could set the mailer_transport to gmail and ommit the port.

    parameters.yml

    mailer_transport: gmail
    mailer_encryption: ssl
    mailer_auth_mode: login
    mailer_host: smtp.gmail.com
    mailer_user: karansofat89@gmail.com
    mailer_password: pass
    

    config.yml

    swiftmailer:
        transport:  %mailer_transport%
        encryption: %mailer_encryption%
        auth_mode:  %mailer_auth_mode%
        host:       %mailer_host%
        username:   %mailer_user%
        password:   %mailer_password%
    

    You should also make sure that the openssl extension is enabled.

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料