I
I
Ivan2021-03-04 15:39:57
Laravel
Ivan, 2021-03-04 15:39:57

How to make in laravel so that letters are sent locally via sendgrid to mailtrap?

Good afternoon. There are currently two mail providers in the project: mailjet and sendgrid. By default, as far as I understand, it costs mailjet, sending through it Mail::to('')or by method. In the file env, the mail is set to mailtrap, and all letters go locally to this mailtrap. But now in many places we send it as a sandgrid by adding mailer('sendgrid'). In the env file, API_KEYFROM_ADDRESS is also added for your sandgrid account. And with local development, emails are sent to real email. And you should always remember this, comment on API_KEY or something like that. Is it possible somehow to force the letters that are sent by the sendgrid through mailer('sendgrid')to go to the mailtrap?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin, 2021-03-07
@derwin

I didn't quite understand your question. If you need to separate the implementation depending on the environment, then: 1) in the code you use the handler, use mailSenderInterface
instead of specifying a specific implementation
2) somewhere at the container level, attach a specific instance of the implementation to a specific environment
just as a success, check the call of the desired function with the desired parameters. It's all in the test.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question