I am trying to send a mail using laravel but am getting this error :
"Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required"
This is my mail.php file
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => null, 'name' => null],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
This is where I send my mail from (routes.php)- for testing though.
Route::get('/send', function(){
mail::send('Email.signup', [], function ($message) {
$message->to('mymail#gmail.com', 'example_name');
$message->subject('Welcome!');
$message->from('hello#app.com', 'Your Application');
});
});
Thank you.
Related
I have Unsupported mail transport" error when send an email in laravel 9 project.
Here is my .env
MAIL_DRIVER = smtp
MAIL_HOST = smtp.gmail.com
MAIL_PORT = 587
MAIL_USERNAME = *****#gmail.com
MAIL_PASSWORD = *******
MAIL_ENCRYPTION = tls
MAIL_FROM_ADDRESS=*****#gmail.com
Here is my config/mail.php
'mailers' => [
'smtp' => [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => '*****', 'name' => '*****'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
],
Please help me. Thanks!
i fixed my config/mail.php like this and it works.
'smtp' => [
'transport' => 'smtp',
'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,
],
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
I am trying to send an email verification for the registering users but I am getting the following error:
Expected response code 250 but got code "530", with message "530-5.5.1
Authentication Required. Learn more at\r\n 530 5.5.1
https://support.google.com/mail/?p=WantAuthError v11sm5345109pgt.0 -
gsmtp\r\n
I have tried all the possible ways by enabling the "less secure" and other instructions but not understanding the error. please help me to sort out the problem.
My .env file is :
My Controller:
My mail.php:
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => env('MAIL_FROM_ADDRESS', 'myaccount#gmail.com'),
'name' => env('MAIL_FROM_NAME', 'Example'), ],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('myaccount#gmail.com'),
'password' => env('*******'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => FALSE,
The problem is in your mail.php, use this code instead of your
...
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'myaccount#gmail.com'),
'name' => env('MAIL_FROM_NAME', 'Example')
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME', 'myaccount#gmail.com'),
'password' => env('MAIL_PASSWORD', '*******'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => FALSE,
...
EDIT:
First parameter of the env() helper method is name of environment variable and second one is a fallback value if that variable isn't found. The reason why it didn't work is because Laravel wasn't able to find an environment variable under the name myaccount#gmail.com and *******.
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.
I am trying to send mail using my gmail account but its not working.
Connection could not be established with host smtp.gmail.com [Connection timed out #110]
.env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=jitendrameena38#gmail.com
MAIL_PASSWORD=*******
MAIL_ENCRYPTION=ssl
and mail.php is -
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => 'jitendrameena38#gmail.com', 'name' => "Minmarks"],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
];
and in my controller -
Mail::raw('This is an test e-mail', function ($message) {
$message->to("jitu#gmail.com", "someone");
$message->subject("hi checking");
$message->getSwiftMessage();
});
What is missing in this. Please help.
Thanks.
You should set
MAIL_DRIVER=sendmail
It works for me.