Symfony 4 Swift Mailer doesn't send mails

情到浓时终转凉″ 提交于 2019-12-08 08:18:26

I had the same problem with Symfony 4. My packages version swiftmailer/swiftmailer v6.1.0 symfony/swiftmailer-bundle v3.2.2 When I used configuration: swiftmailer: url: '%env(MAILER_URL)%' spool: { type: 'memory' }

The emails were not send and no exception occurred. Then I change the settings into:

swiftmailer: url: '%env(MAILER_URL)%' spool: type: 'file' path: '%kernel.cache_dir%/swiftmailer/spool'

And tried command:

php bin/console swiftmailer:spool:send --env=dev -vvv

And I saw the error:

[Swift_SwiftException]
No IDN encoder found (install the intl extension or the true/punycode package
So I installed true/punycode package via:

composer req true/punycode

and now emails are sending fine also with spool memory.

Default behaviour of Symfony mailer is to send the email messages immediately, but as you configured, it will "spool" the emails instead of sending them directly.

spool: { type: 'memory' }

Sending the messages from the spool is done separately, with a console command:

php bin/console swiftmailer:spool:send --env=dev

@see more docs here

UPDATE: As @nek said on the first comment, the the memory spool send the mail immediately (if none exception occured). The spool:send command is only required when using the file spool.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!