How to fix error Swift_TransportException in Laravel 5.6 - php

working with laravel 5.6 and I am going to send contact form details via the gmail. My .env file is look like this,
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myname#gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=null
but when I send submit buttons following error is coming,
1/1) Swift_TransportException
Expected response code 250 but got code "530", with message "530 5.7.0 Must issue a STARTTLS command first. u21-v6sm32263983pfa.176 - gsmtp
"
in AbstractSmtpTransport.php line 383
how can fix this project?

I guess I have faced this issue when I had wrong password in .env for given email id

Related

Error when I send email using Office365 in Laravel

In Laravel 7, I want to send email from my application using Office365, tried email password and app password none worked.
MAIL_MAILER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=my-email-here
MAIL_PASSWORD=my-email-password-here
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=my-email-here
MAIL_FROM_NAME="App name"
In the above code MAIL_PASSWORD is my email password not app password
this configuration gives me the following error
Failed to authenticate on SMTP server with username "support#tingsapp.com" using 2 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "451", with message "451 4.7.0 Temporary server error. Please try again later. PRX4 [MRXP264CA0044.FRAP264.PROD.OUTLOOK.COM]
". Authenticator XOAUTH2 returned Expected response code 235 but got code "535", with message "535 5.7.3 Authentication unsuccessful [MRXP264CA0044.FRAP264.PROD.OUTLOOK.COM]
In the second try I put App Password created in office.com as MAIL_PASSWORD value, but I get same error.
after changing the .env I run php artisan cache:clear and php artisan config:cache
Is there anything I missed, please
you need to put the password in double-quotes.
Replace: MAIL_PASSWORD=yourpassword
With: MAIL_PASSWORD="yourpassword"
after changing the .env just run:
php artisan cache:clear
You have to use your email instead of password on MAIL_FROM_ADDRESS like this
MAIL_MAILER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=my-email-here
MAIL_PASSWORD=my-email-password-here
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=my-email-here
MAIL_FROM_NAME="App name"
or you can use smtp-mail.outlook.com as MAIL_HOST
MAIL_MAILER=smtp
MAIL_HOST=smtp-mail.outlook.com
MAIL_PORT=587
MAIL_USERNAME=my-email-here
MAIL_PASSWORD=my-email-password-here
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=my-email-here
MAIL_FROM_NAME="App name"

Laravel 5.6 Swift_TransportException Expected response code 250 but got code , with message PLAIN250 Reset OK

I'm trying to send email using Laravel 5.6 but I got this error
Swift_TransportException Expected response code 250 but got code , with message PLAIN250 Reset OK
This is my configuration:
MAIL_DRIVER=smtp
MAIL_HOST=4403.smtp.antispamcloud.com
MAIL_PORT=587
MAIL_USERNAME=username#domain.tld
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
Any ideas? Thx
Check your gmail account: in settings, enable access for less secure apps and it will work.

Laravel 5.4 Swift_TransportException: response code 250 but got code "501", with message "501

When I try to send an email in production it returns me this error:
[2017-10-23 18:54:17] local.ERROR: Swift_TransportException: Expected
response code 250 but got code "501", with message "501 Invalid
command or cannot parse from address " in
/var/www/laravel/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:383
but same time I have a contact form on this domain and it works fine!
Why is this happening?
I both cases i use :
Mail::to($user->email)->bcc('tokyo#website.jp ')->queue(new BuyerComment($data));
This is my .env:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=2525
MAIL_USERNAME=*********
MAIL_PASSWORD=**********
MAIL_ENCRYPTION=tls
Ok! I got it the problem was just in my code!
>bcc('tokyo#website.jp ')
has to be:
>bcc('tokyo#website.jp')
A stupid mistake a, space in the end! lol

Sending email in heroku host since laravel 5.4

I am trying to send an email confirmation account from a web application made in laravel 5.4, I have tested in my localhost and it is sent correctly, but when deployed in heroku throws me this error:
Swift_TransportException in AbstractSmtpTransport.php line 383:
Expected response code 250 but got code "530", with message "530-5.5.1
Authentication Required.
Learn more at
530 5.5.1 https://support.google.com/mail/answer/14257 w10sm15831823wjk.18 -
gsmtp"
I have already configured the application key from gmail, even the tests from the localhost are positive, but since heroku fails to send the email.
These are my settings in the .env file:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=micorreo#gmail.com
MAIL_PASSWORD=mvallokmzmszjtwk
MAIL_ENCRYPTION=tls
You have to configure add-on mail in heroku https://devcenter.heroku.com/articles/smtp

Laravel 5: Sending Email

I am trying to send an email in laravel application.
Here is my .env file:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=ehsan.sani91#gmail.com
MAIL_PASSWORD=**********
MAIL_ENCRYPTION=tls
And here is the Mail::send method:
Mail::send('email', ['name' => "EE"], function($m){
$m->to('ee#dx.com', 'Malik')->subject('Subjet of the email');
});
And here is the error:
Swift_TransportException in AbstractSmtpTransport.php line 383: Expected response code 250 but got code "530", with message "530 5.7.0 Must issue a STARTTLS command first. s16sm7748968wib.16 - gsmtp"
Any help?
Well, I got it. Infact the email was not authenticated because that email required a mobile phone authentication after login. changing to other email address that required just login credentials, it worked.
.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=youremail#host.com
MAIL_PASSWORD=yourpassword
MAIL_ENCRYPTION=tls
GMail SMTP requires encryption. Try changing setting as following.
MAIL_PORT=465
MAIL_ENCRYPTION=ssl
I made the following mistake:
I did not actually include the
'encryption' => env('MAIL_ENCRYPTION'),
to the array return in mail.php. I did include my host, port, username and password in the mail.php but not the encryption method (the encryption method I only included in the .env file), so trying out these mentioned solutions did bring a change in the error messages outcome, created a bigger confusion, but none solved the problem. Hope this helps someone!

Categories