phplaravellaravel-9symfony-mailer

Cannot send emails using Laravel 9


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="noreply@example.com"
MAIL_FROM_NAME="${APP_NAME}"

Solution

  • 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.