无法使用Laravel 9发送电子邮件

发布于 2025-02-07 10:24:25 字数 893 浏览 2 评论 0原文

我最近更新到Laravel 9,现在我不再能够发送电子邮件。在更新日志中,他们将邮件从SwiftMailer切换到Symfony,因此也许这是问题的根源。 这是每当我尝试发送邮件时会遇到的错误的正文:

Symfony\Component\Mailer\Exception\TransportException: Unable to write bytes on the wire. in file C:\OpenServer\domains\minecraftstorage\vendor\symfony\mailer\Transport\Smtp\Stream\AbstractStream.php on line 46

我遵循文档,配置了我的 .env config/mail.php 文件。我确定那一侧的一切都是正确的。对于SMTP服务器,我正在使用MailTrap,因此从那里进行邮件配置。我花了两天时间尝试解决这个问题,在互联网上进行了搜索,但没有成功。重新安装作曲家依赖性也无济于事。

以下是我的 .env 邮件配置:

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=**************
MAIL_PASSWORD=**************
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

I recently updated to Laravel 9 and now I am no longer able to send emails. In the update log its written that they switched mailer from SwiftMailer to Symfony, so maybe this is the root of the problem.
This is the body of the error that I get whenever I try to send a mail:

Symfony\Component\Mailer\Exception\TransportException: Unable to write bytes on the wire. in file C:\OpenServer\domains\minecraftstorage\vendor\symfony\mailer\Transport\Smtp\Stream\AbstractStream.php on line 46

I followed the documentation, configured my .env and config/mail.php files. I am sure everything is correct on that side. For SMTP server I am using MailTrap, hence mail configuration is taken from there. I have spent two days trying to solve this problem, searched all over the internet, but with no success. Reinstalling composer dependencies does not help too.

Below is my .env configuration for mail:

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=**************
MAIL_PASSWORD=**************
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深府石板幽径 2025-02-14 10:24:25

我终于找到了解决方案。事实是,我的互联网提供商以某种方式阻止了SMTP连接。因此,当我从WiFi转换为移动数据时,它突然开始工作。希望这对遇到类似问题的其他人有帮助。

I finally found the solution. Thing was that my internet provider was somehow blocking smtp connection. So as I switched from my Wifi to mobile data, it suddenly started to work. Hope this helps others who come across similar issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文