Reputation: 879
I want to send mail from my local machine using laravel 5.4 in a forget password API. But I am getting Swift_TransportException
(1/1) Swift_TransportException
Expected response code 220 but got code "502", with message "502 Command not implemented
"
The .env details is
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
[email protected]
MAIL_FROM_NAME=Project.com
The code I am getting error is
$response = $this->broker()->sendResetLink(
$request->only('email')
);
The code in config/mail.php is
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
How can I enable mailing from my local machine? Does I have to enable port for that?
Upvotes: 8
Views: 11179
Reputation: 15
refer to it's official help site:
If you want to using Gmail, it banned this option: To help keep your account secure, from May 30, 2022, Google no longer supports the use of third-party apps or devices which ask you to sign in to your Google Account using only your username and password.
Important: This deadline does not apply to Google Workspace or Google Cloud Identity customers. The enforcement date for these customers will be announced on the Workspace blog at a later date.
Upvotes: 0
Reputation: 180
try this configuration in .env
file, it allways works for me.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=userpassword
MAIL_ENCRYPTION=ssl
and configure your config/mail.php
like so:
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false
]
]
ps: you'll need to configure your [email protected] account to allow less secure application to use it
Upvotes: 0
Reputation: 2657
Just a thought:
Try use mailtrap.io on local development machine. It's easy to configure and laravel supports it out of the box. Shouldn't bother your production mail server during development.
Cheers!
Upvotes: 2
Reputation: 339
You can download and use fakesmtp http://nilhcem.com/FakeSMTP/ for localhost and set port :25 by default..for any framework its support for local server machines . Only you need to start whenever you want send mail and check the mails log in fakesmtp.
Upvotes: 3