与Symfony Mailer一起发送电子邮件
我有Symfony 5.4的新安装。我遵循了文档,以从我自己的SMTP服务器发送电子邮件,但无法使其正常工作。因此,我正在尝试 https://mailtrap.io/ 带有以下配置,没有运气。任何帮助都将受到赞赏。
遵循的步骤
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)%'
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.
Steps followed
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)%'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
运行:
然后运行:
Run:
Then run:
如果您使用-docker选项安装了Symfony,则您的Docker-compose.override.yml文件将在添加Symfony Mailer时包含邮件捕捉器的配置。
来自官方Symfony网站: https:// symfony。 com/doc/current/the-fast-track/en/3-Zero.html
-docker:在您的本地计算机上,我们将使用Docker来管理PostgreSQL之类的服务。此选项启用Docker,以便Symfony将根据所需的软件包自动添加Docker服务(例如,在添加symfony Mailer时添加ORM或邮件捕获器时的PostgreSQL服务)。
在您的 profiler bar,悬停在“服务器上”,以揭示一系列选项这是网络邮件。如果您的项目中所述的配置存在,则您的网络邮件将在那里交付。
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.