Reputation: 346
I have fresh installation of Symfony 5.4. I have followed the documentation in order to send email from my own smtp server but couldn't make it work. So, I'm trying https://mailtrap.io/ with the following configurations with no luck. Any help is appreciated.
composer require symfony/mailer
composer require symfonycasts/verify-email-bundle
MAILER_DSN=smtp://d62b667a28d6af:[email protected]:2525
#MAILER_DSN=smtp://d62b667a28d6af:[email protected]:2525?encryption=tls&auth_mode=login
RegistrationController
// generate a signed url and email it to the user
$this->emailVerifier->sendEmailConfirmation('app_verify_email', $user,
(new TemplatedEmail())
->from(new Address('registration@my_host.com', 'Registration Confirmation'))
->to($user->getEmail())
->subject('Please Confirm your Email')
->htmlTemplate('registration/confirmation_email.html.twig')
);
mailer.yml
framework:
mailer:
dsn: '%env(MAILER_DSN)%'
Upvotes: 1
Views: 2822
Reputation: 31
Run:
composer require symfony/messenger
Then run:
php bin/console messenger:consume async
Upvotes: 3
Reputation: 121
If you installed Symfony with the --docker option, then your docker-compose.override.yml file will contain a configuration for a mail catcher when you add symfony mailer.
From the official Symfony website: https://symfony.com/doc/current/the-fast-track/en/3-zero.html
--docker: On your local machine, we will use Docker to manage services like PostgreSQL. This option enables Docker so that Symfony will automatically add Docker services based on the required packages (a PostgreSQL service when adding the ORM or a mail catcher when adding Symfony Mailer for instance).
In your Profiler bar, hover over "Server" to reveal an array of options one of which is Webmail. Your webmail will be getting delivered there if the configuration described above exists in your project.
Upvotes: 1