Laravel 5.4 SMTP error "send AUTH command first" - php

I'm getting the following error trying to send mail from localhost using smtp:
Expected response code 250 but got code "503", with message "503 5.5.4
Error: send AUTH command first. "
.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.yandex.com
MAIL_PORT=465
MAIL_USERNAME=robot#domain.com
MAIL_PASSWORD=11111111
MAIL_ENCRYPTION=ssl
MAIL_FROM=robot#domain.com
MAIL_NAME=MY.NAME
config/mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.yandex.com'),
'port' => env('MAIL_PORT', 465),
'from' => [
'address' => 'robot#domain.com',
'name' => 'MY.NAME',
],
'encryption' => env('MAIL_ENCRYPTION', 'ssl'),
'username' => env('robot#domain.com'),
'password' => env('11111111'),
'sendmail' => '/usr/sbin/sendmail -bs',
];
Tried: changing ports, encryption, clearing cache, restarting server in all possible combinations. :)
As I see it there's one more parameter I need to pass to the mailer library. Some thing like
auth_mode=login_first
Can this be done through laravel settings?

I'm posting my working settings. You've got to check how laravel env helper function is used in your config file. Also when using smtp.yandex.com auth email and form email must match.
Laravel Docs for env()
The env function gets the value of an environment variable or returns a default value:
$env = env('APP_ENV');
// Return a default value if the variable doesn't exist...
$env = env('APP_ENV', 'production');
.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.yandex.com
MAIL_PORT=465
MAIL_USERNAME=robot#mydomain.com
MAIL_PASSWORD=123123123
MAIL_ENCRYPTION=ssl
MAIL_FROM=robot#mydomain.com
MAIL_NAME=MY.NAME
config/mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.yandex.com'),
'port' => env('MAIL_PORT', 465),
'from' => [
'address' => env('MAIL_FROM','robot#mydomain.com'),
'name' => env('MAIL_NAME','MY.NAME'),
],
'encryption' => env('MAIL_ENCRYPTION', 'ssl'),
'username' => env('MAIL_USERNAME','robot#mydomain.com'),
'password' => env('MAIL_PASSWORD','123123123'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
Controller function
public function testmail()
{
$user = Auth::user();
$pathToLogo = config('app.url').'/images/logo/logo_250.png';
Mail::send('emails.testmail', array('user' => $user, 'pathToLogo' => $pathToLogo), function($message) use ($user)
{
$message->to($user->email);
$message->subject('Test message');
});
return redirect()->route('home')->with('message','Test message sent.');
}

Related

Email Not Being Sent in Laravel 8 using Mailgun Smtp

My email set up works well and send emails using my mailtrap set up but when I change the .env and mail.php file to that of Mailgun it does not sends the email. I only get a success message without any email. The emails I am using for testing are verified in my mailgun accounts
.ENV
MAIL_MAILER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=postmaster#sandboxaf*********.mailgun.org
MAIL_PASSWORD=3b0d1862f55dcb18c62b***********
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=test#gmail.com
MAIL_FROM_NAME="${APP_NAME}"
MAIL_SECRET=53774448859c1ffa6fad57b4a8*****************
MAIL_DOMAIN=sandboxaf49fa3222d1441e8*********.mailgun.org
MAIL_PASSWORD=3b0d1862f55dcb18c62bf***************
Mail.php
'default' => env('MAIL_MAILER', 'mailgun'),
'mailers' => [
'smtp' => [
'transport' => 'mailgun',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'auth_mode' => null,
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
],
]
Controller
Mail::to($request->email)->send(new PasswordResetMail($code,$url));
if (Mail::failures()) {
return response('failure');
}
else{
return response('success');
}
Have tried working on the suggestions from this
linkEmail Not Being Sent in Laravel 8 using Mailgun APIand this linkMailgun emails not sending from Laravel 8 Valet app as well as other links without any success

How to achieve password reset functionality in laravel 5.4

I implemented laravel 5.4 auth login. My other functionality is in working like login, logout etc. But for password reset functionality I am receiving following error. I am confused where I am wrong.
Swift_TransportException in StreamBuffer.php line 268: Connection
could not be established with host smtp.thenaturalgolfcourse.com
[php_network_getaddresses: getaddrinfo failed: Name or service not
known #0]
Below is my .env file detail is reqired for mail setting.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mysite.com
MAIL_PORT=465
MAIL_USERNAME=support#mysite.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
same details I used in mail.php like below
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mysite.com'),
'port' => env('MAIL_PORT', 465),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'support#mysite.com'),
'name' => env('MAIL_FROM_NAME', 'The My Site'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME','support#mysite.com'),
'password' => env('MAIL_PASSWORD','mypassword'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
Please give me solution or tell me where I am wrong..

vagrant laravel 5.3 gmail Expected response code 250 but got code "", with message ""

There are many post regarding this problem but none of them seems to fix my problem.
I'm trying to send email using gmail account from my local vagrant box.
My mail config:
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => 'myaccount#gmail.com',
'name' => 'Example',
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
.env file:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myaccount#gmail.com
MAIL_PASSWORD=16digit_gmail_app_password
MAIL_ENCRYPTION=tls
My code:
\Mail::send('email.order',[], function($message) {
$message->to('other_email#email.com', 'John Smith')
$message->subject('Welcome!');
});
In my gmail account I acctivated 2-Step Verification and I created a app password (select app -> mail, select device -> Other/myLocalDomain.
When I try to send email I get Expected response code 250 but got code "", with message ""
I'm probably missing something here but I can't figure what.

Error when try to use mandrill for password resetting on Laravel 5

I try to create a password resetting system on laravel 5 and this what I do:
1. Route.php
Route::get('/password/email','Auth\PasswordController#getEmail');
Route::post('/password/email','Auth\PasswordController#postEmail');
Route::get('/password/reset/{token}','Auth\PasswordController#getReset');
Route::post('/password/reset','Auth\PasswordController#postReset');
2. .env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mandrillapp.com
MAIL_PORT=587
MAIL_USERNAME=*****#gmail.com
MAIL_PASSWORD=********
3. composer.json
...
"require": {
....
....
"guzzlehttp/guzzle": "~5.0"
},
...
4. mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mandrillapp.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => "****#gmail.com", 'name' => "****"],
'encryption' => 'tls',
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
when i try it i get a success message on the page but i don't receive any email.
Try use mandrill driver
Add your key in config/services.php and change your mail driver in .env to mandrill
See it in: https://laravel.com/docs/5.2/mail

Laravel 5.1 Mail::send how to know why it don't sends mails?

I am trying Laravel do a mail send. When I execute the code, nothing happens, no errors, no logs, no returning mails, anything.
Config Env
MAIL_DRIVER=smtp
MAIL_HOST=mail.domain.es
MAIL_PORT=587
MAIL_USERNAME=noreply#domain.es
MAIL_PASSWORD=xxxxxx
MAIL_FROM=noreply#domain.es
MAIL_NAME=Domain Name
MAIL_ENCRYPTION=null
Mail.php
return [
'driver' => 'smtp',
'host' => env('MAIL_HOST', 'mail.domain.es'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => 'noreply#domain.es', 'name' => 'Domain Name'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME', 'noreply#domain.es'),
'password' => env('MAIL_PASSWORD', 'xxxxx'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => env('MAIL_PRETEND', true),
];
Code in the controller
$accion = Accion::findOrFail($id);
Mail::send('emails.notificar', ['accion' => $accion], function ($m) use ($accion) {
$m->from(env('MAIL_FROM'), env('MAIL_NAME'));
$m->to("jtd#adagal.es", "Jtd")->subject('Nova acción formativa');
});
Did you see any error? I did everything that is marked in the official docs but still no response, no mail, no error.
pretend' => env('MAIL_PRETEND', true) change this to false
When the mailer is in pretend mode, messages will be written to your application's log files instead of being sent to the recipient.

Categories