Send email using Symfony Mailer
P粉211600174
P粉211600174 2023-11-09 21:03:31
0
1
698

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粉211600174
P粉211600174

reply all (1)
P粉115840076

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

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!