Home  >  Q&A  >  body text

Send email using Symfony Mailer

I did a fresh install of Symfony 5.4. I've followed the documentation to send an email from my own smtp server but can't get it to work. So I'm trying to use the following configuration of https://mailtrap.io/ without success. Any help would be greatly appreciated.

Steps to follow

composer requires symfony/mailer

composer requires symfonycasts/verify-email-bundle

MAILER_DSN=smtp://d62b667a28d6af:023c577a51bb51@smtp.mailtrap.io:2525 #MAILER_DSN=smtp://d62b667a28d6af:023c577a51bb51@smtp.mailtrap.io:2525?encryption=tls&auth_ mode=Login

Register Controller

...

        // 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)%'


P粉211600174P粉211600174368 days ago846

reply all(1)I'll reply

  • P粉115840076

    P粉1158400762023-11-10 10:24:24

    Running Composer requires symfony/messenger Then Run php bin/console messenger:consume async

    reply
    0
  • Cancelreply