1
votes

I face a problem I don't understand.

I use SwiftMailer to send emails (ex : registration confirmation) from a website using the Mailjet SMTP. Mails are not sent.

The Symfony profiler says that 1 mail is spooled when I create a user account, but it is never sent. php bin/console swiftmailer:spool:send returns 0 emails sent. I tried memory and file spools.

When using the php bin/console swiftmailer:email :send, mails are correctly sent (mails have the mailjet headers and they are in the mailjet sent mails interface).

When I'm trying the OVH SMTP, mails are correcly sent both from the application and cli command, so the problem seems to be a SwiftMailer misconfiguration.

Here is my setup :

app/config/config.yml

swiftmailer:
    transport: "%mailer_transport%"
    host:      "%mailer_host_prod%"
    port:      "%mailer_port_prod%"
    encryption:"%mailer_encryption_prod%"
    username:  "%mailer_user_prod%"
    password:  "%mailer_password_prod%"
    spool:     { type: memory }

app/config/parameters.yml

mailer_transport: smtp

mailer_host_prod: in-v3.mailjet.com
mailer_port_prod: 587
mailer_encryption_prod: tls
mailer_user_prod: api_key
mailer_password_prod: api_secret

mailer_host_ovh: ssl0.ovh.net
mailer_port_ovh: 465
mailer_encryption_ovh: ssl
mailer_user_ovh: email
mailer_password_ovh: password
3
I don't understand your question. swiftmailer:email:send successfully sends emails, so what's the problem?Stephan Vierkant
I have edited my post, I hope that it will be more comprehensibleAl3

3 Answers

1
votes

It works for me. I had the same issue, but I had an exit after sending the email and in this case, the spool doesn't send the email, because the kernel does not end properly. If you remove spool: { type: memory }, then it will send the email.

To send the email properly with spool, then you need to end the kernel properly.

0
votes

Did your request finish without any errors when creating the message ?

On https://symfony.com/doc/current/email/spool.html : "This means the email only gets sent if the whole request got executed without any unhandled exception or any errors."

0
votes

Finally, it was the sender's email who was wrong. I forgot to update it after going prod. At this moment, Mailjet successfuly receive the email but put it in queue and don't send it. On Symfony side, it is a success.