Skip to content

Mailer stop setting on fly SMTP due to usage of Symfony mailer #42602

@ghost

Description

Laravel Version: 9.11
PHP Version: 8.0.1
Database Driver & Version: MySQl
Description:
In the early versions of Laravel (6-8) I was able to set the on the fly SMTP configuration for the mail in the queue using swift mailer. But now, due to the removal of Swift mailer, and addition symfony mailer, I am unable to set the on custom STMP on the fly for the users.

The method (Mailer::setSymfonyTransport(TransportInterface $transport);) works fine if the mail is not sent in the queue. However, it stopped working with the queue.

It directly takes the default SMTP.

Steps To Reproduce:
To reproduce the error, please follow below steps

  1. In web.php, in the welcome route, create new SMTP transport using MailManager::createSymfonyTransport($config);
  2. set new transport using Mailer::setSymfonyTransport(TransportInterface $transport);
  3. Create new mail, which implements ShouldQueue
  4. Try to send the mail with the queue functionality.

https://github.com/PareshP-RSW/bug-report
Here I have created the repo. to regenerate the issue.

The repo contains two mail configuration, you can see it in the .env.example (just to show you. In real life it will be base on tenants.So there could be 1000 different SMTP)
Enter smtp config for both the settings.
migrate the DB
Enable the queue in .env
This project has two mailer routes. mail-with-queue and mail-without-queue
mail-with-queue will set the custom config first and then it will put the mail in queue
mail-without-queue will set the custom config first and then it will directly send the email
Issue

=> It set the custom SMTP while sending the mail directly.
=> It uses the default SMTP when sending the mail using queue. (Setting up custom config does not work)

Expected behaviour
=> Custom SMTP should work on Queue also.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions