symfony swiftmailer:邮件未在prod-environment中发送

时间:2022-10-16 12:29:30

I have a symfony 2.8 app, with fosuserbundle implemented. In the dev environment, the registration confirm mails are sent, but not in the prod environment. There is no log message and the smpt configuration is correct.

我有一个symfony 2.8应用程序,实现了fosuserbundle。在开发环境中,会发送注册确认邮件,但不会在prod环境中发送。没有日志消息,并且smpt配置正确。

sf version: 2.8.1 swiftmailer-bundle version: current (compatible with sf version; 2.* in composer json) fosuserbundle: 1.3.5 (* in composer)

sf版本:2.8.1 swiftmailer-bundle版本:current(与sf版本兼容; 2. *在composer json中)fosuserbundle:1.3.5(*在作曲家中)

dev-config:

imports:
    - { resource: config.yml }

framework:
    router:
    resource: "%kernel.root_dir%/config/routing_dev.yml"
    #strict_requirements: true
    profiler: { only_exceptions: true }

web_profiler:
    toolbar: true
    intercept_redirects: true

assetic:
    use_controller: true

Has anyone the same problem?

有谁有同样的问题?

edit

I just tried a mail with the following console command in prod env: php sf --env=prod swiftmailer:email:send

我刚刚在prod env中使用以下控制台命令尝试了一封邮件:php sf --env = prod swiftmailer:email:send

Terminal output:

#!/usr/bin/env php
From: test@antondachauer.de
To: mail@antondachauer.de
Subject: test
Body: test
Sent 1 emails

But the mail has not been sent. In the dev env, it works also in terminal.

但邮件尚未发送。在开发环境中,它也适用于终端。

1 个解决方案

#1


0  

I tried all the solutions mentioned here, which is "gethostbyname" and "change smtp of Gmail" but it did not work.

我尝试了这里提到的所有解决方案,即“gethostbyname”和“更改Gmail的smtp”,但它没有用。

After a few days of digging, I found a solution, you need to change the encryption to tls, and add ssl in stream_options in config. It's not recommended according to the security standpoint, but it works in my case.

经过几天的挖掘,我找到了一个解决方案,你需要将加密更改为tls,并在config中的stream_options中添加ssl。根据安全角度不建议这样做,但它适用于我的情况。

parameters.yml

mailer_prod_encryption: tls

config.yml

swiftmailer:
  transport:  "%mailer_dev_transport%"
  host:       "%mailer_dev_host%"
  username:   "%mailer_dev_user%"
  password:   "%mailer_dev_password%"
  encryption: "%mailer_dev_encryption%"
  auth_mode:  "%mailer_dev_auth_mode%"
  spool:     { type: memory }
  port: 25
  stream_options:
    ssl:
      allow_self_signed: true
      verify_peer: false

#1


0  

I tried all the solutions mentioned here, which is "gethostbyname" and "change smtp of Gmail" but it did not work.

我尝试了这里提到的所有解决方案,即“gethostbyname”和“更改Gmail的smtp”,但它没有用。

After a few days of digging, I found a solution, you need to change the encryption to tls, and add ssl in stream_options in config. It's not recommended according to the security standpoint, but it works in my case.

经过几天的挖掘,我找到了一个解决方案,你需要将加密更改为tls,并在config中的stream_options中添加ssl。根据安全角度不建议这样做,但它适用于我的情况。

parameters.yml

mailer_prod_encryption: tls

config.yml

swiftmailer:
  transport:  "%mailer_dev_transport%"
  host:       "%mailer_dev_host%"
  username:   "%mailer_dev_user%"
  password:   "%mailer_dev_password%"
  encryption: "%mailer_dev_encryption%"
  auth_mode:  "%mailer_dev_auth_mode%"
  spool:     { type: memory }
  port: 25
  stream_options:
    ssl:
      allow_self_signed: true
      verify_peer: false