我全新安裝了 Symfony 5.4。我已按照文件從我自己的 smtp 伺服器發送電子郵件,但無法使其工作。因此,我正在嘗試使用以下配置的 https://mailtrap.io/ ,但沒有成功。如有任何幫助,我們將不勝感激。
composer 需要 symfony/mailer
composer 需要 symfonycasts/verify-email-bundle
MAILER_DSN=smtp://d62b667a28d6af:023c577a51bb51@smtp.mailtrap.io:2525 #MAILER_DSN=smtp://d62b667a28d6af:023c57a51tp
#
註冊控制器
... // 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)%'
#
運行 Composer 需要 symfony/messenger 然後 運行 php bin/console messenger:consume async