简体   繁体   中英

Mail stay in queue when i use Sendgrid in symfony6

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 未显示错误代码,但邮件仍在排队

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,

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM