I am trying to send an email from Laravel, but it's giving an ErrorException. I am using gmail with generated application password.
I've tried both the protocols, SSL and TLS with their respective ports. Also tried making changes in options array in Swift\Transport\StreamBuffer
verify_peer => false,
verify_peer_name => false
The settings in my environment file are:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail@gmail.com
MAIL_PASSWORD=myApplicationPassword
MAIL_ENCRYPTION=tls
The error I received is:
fwrite(): send of 17 bytes failed with errno=10054 An existing connection was forcibly closed by the remote host. in StreamBuffer.php line 240
at HandleExceptions->handleError(8, 'fwrite(): send of 17 bytes failed with errno=10054 An existing connection was forcibly closed by the remote host. ', 'D:\\xampp2\\htdocs\\express\\vendor\\swiftmailer\\swiftmailer\\lib\\classes\\Swift\\Transport\\StreamBuffer.php', 240, array('bytes' => 'HELO [IPv6:::1] ', 'bytesToWrite' => 17, 'totalBytesWritten' => 0))
I've also filled from and reply_to array with my Email Address and Name in config/mail.php
The code for sending mail is:
Mail::to($user->email)->send(new WelcomeMail);
Kindly tell me, the reason behind this error, can it be solved without hacking core files? What alternatives are available to me?