Mail stay in queue when i use Sendgrid in symfony6

1.3k views Asked by At

I have set my Sendgrid single sender and validate it ( status = verified).

I use SMTP, create my key that i paste in my code (.env file of my app): MAILER_DSN=sendgrid+smtp://@default

Then i try to test integration in Sendgrid by clicking on button and refresh my localhost/ page (of course the controller's route is "/" and it contains the code using mailer to send a mail as explain in mailer documentation).

On my vue i don't have error code but mail stay in queue status...

Here the screenshot taken of the profiler:

Profiler showing no error code but mail stay queued

Can someone tell me why my mail stay queued?

Of course the From email address is mine ( the verified one) and the To is anotherone of mine.

Maybe i have to configure something in my outlook mail (the From one) ?

Sendgrid never match the verification, it stay in checking status until message :

Hmm, we haven't seen your email yet.

Please check your code, run it again, then click "Retry".

Thanks for reply,

Regards,

2

There are 2 answers

0
Tom60 On BEST ANSWER

Yes, thanks you a lot for reply.

Of course all was set as you notify me.

I now have fix my issue, in fact the problem for me with the mail that remains in queued is that the messenger was installed so in asynchronous by default.

I had to add the option message_bus: false in my config/packages/mailer.yaml file not to have the asynchronous option used.

Hopefully this is useful for some people.

add the option message_bus: false in my config/packages/mailer.yaml:

framework:
  mailer:
    dsn: '%env(MAILER_DSN)%'
    message_bus: false
0
philnash On

In your question you said that your MAILER_DSN environment variable is set to:

MAILER_DSN=sendgrid+smtp://@default

That is missing your API Key though. You need to create an API key in the SendGrid dashboard and then add the API key to the MAILER_DSN variable, between the // and the @default like this:

MAILER_DSN=sendgrid+smtp://API_KEY@default

One other thing, ensure that you have installed the SendGrid transport with this command:

composer require symfony/sendgrid-mailer