I know it is a duplicate issue in StackOverFlow (Laravel SwiftMailer : Expected response code 250 but got code "530", with message "530-5.5.1 Authentication Required) however, I'm done all the remedies discussed there but still no luck. I'm using mailtrap.io using my GMail account. Here is the .env file and mail.php (under config):
.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=XXXX
MAIL_PASSWORD=XXXX
MAIL_ENCRYPTION=tls
mail.php
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailtrap.io'),
'port' => env('MAIL_PORT', 2525),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'niladriXXX#XXX.com'),
'name' => env('MAIL_FROM_NAME', 'Niladri Banerjee'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'sendmail' => '/usr/sbin/sendmail -t -i',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
After submitting the valid email from forgot password screen, it throws the following error:
Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required "
Please note: I have already ON 'Allow less secure apps' from "Sign-in & security" from my GMail.
Seeking your help.
PS: I'm running the project in localhost.
I' may suggest you use this as well, it worked for me,
Please Note if you're using Gmail: create a gmail app password, but be sure to your 2 Step verification set up, from sign in and securiity, the following link: https://myaccount.google.com/apppasswords to setup app password,
use that and follow procedure 2 after this return to set up gmail with smtp.
please note: code down below are for mail.php file
(do not forget to use: php artisan config:cache)
after changes to .env file as well
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailtrap.io'),
'port' => env('MAIL_PORT', 2525),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'lxxxx#xxxx.com'),
'name' => env('MAIL_FROM_NAME', 'myMail'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),//this setting in .env only leave as is here
'password' => env('MAIL_PASSWORD'),//this setting in .env only leave as is here
'sendmail' => '/usr/sbin/sendmail -bs',
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
//procedure 2 for gmail
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'lxxxx#gmail.com'),
'name' => env('MAIL_FROM_NAME', 'myMail'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),//this setting in .env only leave as is here
'password' => env('MAIL_PASSWORD'),//this setting in .env only (use app password you created for gmail and PLEASE leave as is here
'sendmail' => '/usr/sbin/sendmail -bs',
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
Hope it helps.
Kind regards
add MAIL_FROM=mailtrap.io username to your .env file
and php artisan config:cache.
if you see, mail.php needs this for authentication
Related
I'm using Laravel 8.4 and I've deployed it on digital ocean droplet, every thing was going fine but suddenly the emails won't get sended and I get this error instead:
ErrorException
stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
Now i tried to add locally that code every one suggested in my mail.php file:
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
And it solved my problem, but everyone says it's not safe, i want a safe solution, especially after i got a mail-threat one week ago from a hacker asking for a ransom and he claims that he found a volnurability in my website (which I doubt) but I still want to be safe, and why do you think this problem happened to me all of a sudden? everything was fine for almost a year, why now! could it be a hacker attack?
here is my .env file just in case:
MAIL_MAILER=smtp
MAIL_HOST=mail.nouha.net
MAIL_PORT=587
MAIL_USERNAME='*****'
MAIL_PASSWORD='*****'
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS='****'
MAIL_FROM_NAME="${APP_NAME}"
and my mail.php file:
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.nouha.net'),
'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',
],
'postmark' => [
'transport' => 'postmark',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => '/usr/sbin/sendmail -bs',
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
],
I am trying to switch from gmail smtp to sendgrid. And I am stuck on the error code "Address in mailbox given [apikey] does not comply with RFC 2822, 3.6.2."
MAIL_MAILER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=25
MAIL_USERNAME=apikey
MAIL_PASSWORD=My_Api_key
MAIL_ENCRYPTION=null
MAIL_FROM_NAME="Test"
MAIL_FROM_ADDRESS=test#email.com
My mail.php
return [
'default' => env('MAIL_MAILER', 'smtp'),
'mailers' => [
'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,
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
],
'postmark' => [
'transport' => 'postmark',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => '/usr/sbin/sendmail -bs',
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
],
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'test#email.com'),
'name' => env('MAIL_FROM_NAME', 'Test'),
],
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
What is my mistake?
RFC 2822, 3.6.2 refers mainly to the address an email is sent from. In your example above you have MAIL_FROM_ADDRESS set to test#email.com which I presume is not an email address you own or have control over.
From the RFC:
In all cases, the "From:" field SHOULD NOT contain any mailbox that does not belong to the author(s) of the message.
I would make sure you have either verified your email address as single sender or performed domain authentication and then use that email address as your MAIL_FROM_ADDRESS.
If you are still having trouble with this, can you share your config/mail.php file too.
I Used Laravel Authentication,And in Reset Password I Want to send Reset Link to email.
My .env is here:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail#gmail.com
MAIL_PASSWORD=MyPassword
MAIL_ENCRYPTION=null
And my mail.php:
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587);
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hanieasemi76#gmail.com'),
'name' => env('MAIL_FROM_NAME', 'hanie'),
],
'encryption' => env('MAIL_ENCRYPTION', 'ssl'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
And Turn on 2-step verification of my gmail,But Now When I Want to send email I give this Error Expected response code 250 but got code "530", with message "530 5.7.0 Must issue a STARTTLS command first. r7-v6sm5414781wrn.83 - gsmtp
How I can fixet it?where is my problem?
I have been trying to send emails from my laravel app with mailgun but cant get it to work.
.env
MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=(Default SMTP Login from mailgun)
MAIL_PASSWORD=**********
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS= hello#****.*****.me
MAIL_FROM_NAME= Me
MAILGUN_DOMAIN=*****.*****.me
MAILGUN_SECRET=key-10*****************************f
mail.php
return [
'driver' => env('MAIL_DRIVER', 'mailgun'),
'host' => env('MAIL_HOST', '*****.******.me'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello#*****.******.me'),
'name' => env('MAIL_FROM_NAME', 'Me'),
'encryption' => env('MAIL_ENCRYPTION', 'ssl'),
'username' => env('postmaster#*****.******.me'),
'password' => env('************'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
services.php
'mailgun' => [
'domain' => env('*****.******.me'),
'secret' => env('key-1******************************f'),
],
Using this url to test
Route::get('/send_test_email', function(){
Mail::raw('Sending emails with Mailgun and Laravel is easy!', function($message)
{
$message->to('finchy70#gmail.com');
});
});
No errors but no emails sent. Also no activity on my mailgun dashboard.
All my mailgun DNS settings are verified for my domain.
Can anyone see what I'm doing wrong?
Looks like you're using the value instead of the name in the config for username, password, domain, and secret. Should be
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
And
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
],
I'm trying to create a contact form using laravel 5.4 and I added my server email details to the .env and the mail.php but I'm getting this error
Swift_TransportException in AbstractSmtpTransport.php line 383:
Expected response code 250 but got code "421", with message "421 Unexpected failure, please try later
"
If I try this and I use mailtrap it works fine.
This is my mail.php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'info#website.co.za'),
'name' => env('MAIL_FROM_NAME', 'Info'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
My .env file
MAIL_DRIVER=smtp
MAIL_HOST=hosting.com
MAIL_PORT=587
MAIL_USERNAME=info#website.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=
Check the config/mail.php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', ''),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => null, 'name' => null],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME', ''),
'password' => env('MAIL_PASSWORD', ''),
'sendmail' => '/usr/sbin/sendmail -bs',
];
Make sure the .env file has the following
MAIL_DRIVER=smtp
MAIL_HOST=hosting website
MAIL_PORT=587
MAIL_USERNAME=your username
MAIL_PASSWORD=your password
MAIL_ENCRYPTION=tls
Also clear the config cache
php artisan config:cache