How to send email from Symfony command with Swiftmailer and GmailBundle?

I’m running on Symfony 4.4.4, and I work with Swiftmailer & GmailBundle to send e-mail from Controller, this is working well.

But if I try to send a mail from a Symfony Command, the Swiftmailer send() method return 0. Which seems to be a common problem when no spool configuration is done.

services.yaml

swiftmailer.mailer.transport.gmail_api: '@AppServiceEmailGmailApiTransport'

And my GmailApiTransport is like this one: GmailApiTransport.php

swiftmailer.yaml

swiftmailer:
 default_mailer: gmail_api
 mailers:
  gmail_api:
   transport: gmail_api

How can I implement the spool service to my gmail_api mailers ?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *