I cannot send the password reset link in the email with the error:
Swift_TransportException in AbstractSmtpTransport.php line 383:
Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required
I have followed this video tutorial but still I could not solve the problem.
.env file
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=52ca17394c74f6
MAIL_PASSWORD=e89831236006c1
MAIL_ENCRYPTION=tls
mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => 'hello#example.com',
'name' => 'Example',
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'sendmail' => '/usr/sbin/sendmail -bs',
];
The mailtrap host is smtp.mailtrap.io and that's not what your .env file has. Also when you make changes to .env file, you should clear the config since it might be cached. You can clear it by running php artisan config:clear
Related
I have a Laravel 5 project, and it is having trouble sending mail from our mail server. This mail server is working for another Laravel project with the almost identical setup.
I get the following error:
(1/1) Swift_TransportException
Expected response code 250 but got code "", with message ""
I have my mail.php file setup as such:
<?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', 'no-reply#xtreme.com.au'),
'name' => env('MAIL_FROM_NAME', 'Xtreme IT'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
And the .env file that is overwriting those settings:
MAIL_DRIVER=smtp
MAIL_HOST=mail.ourdomain.com.au
MAIL_PORT=25
MAIL_USERNAME=username#ourdomain.com.au
MAIL_PASSWORD=OURPASSWORD
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=no-reply#clientdomain.com.au
MAIL_FROM_NAME="Client"
Is there an easy way to check that my .env file is being used?
I can't work out why the mail will send on one site but not another.
Answering to the question: "Is there an easy way to check that my .env file is being used?"
You can use the env and config helpers doing:
dd(env($var_name), config($var_name));
Using it, you'll can see if they're the same.
If not, is possible that config cache is outdated, so you can try:
php artisan config:clear
and then
php artisan config:cache
Good look!
I am receiving the following error shown below when attempting to use Mailgun to send a confirmation email from my Laravel project.
Here is my .env file:
MAIL_DRIVER=mailgun
MAILGUN_DOMAIN=sandbox......mailgun.org
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=postmaster#sandbox......mailgun.org
MAIL_PASSWORD=password
MAILGUN_SECRET=key-....
MAIL_FROM=cloud#sandbox.....mailgun.org
MAIL_ENCRYPTION=tls
Here is my mail.php file:
'driver' => env('MAIL_DRIVER', 'mailgun'),
'host' => env('MAIL_HOST', 'smtp.mailgun.com'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
And this is in my composer.json:
"guzzlehttp/guzzle": "^6.2"
Any help of any kind at all would be so greatly appreciated. I simply don't understand the issue.
These are the possible quick fixes have a try in the order I explained,
1) do a composer update and composer dump-autoload once
2) clear the config cache by running php artisan config:clear
If nothing works try changing the package to "guzzlehttp/guzzle": "~5.3|~6.0" and run the above commands to install the package and clear the config cache.
It should work when you run the second step.
I am using mailgun driver in laravel app and tried to send mail. But it gives me this error
Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required
config/mail.php
'driver' => env('mailgun', 'smtp'),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'arshaikh_17#hotmail.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
.env
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
services.php
'mailgun' => [
'domain' => env('mydomain.com.pk'),
'secret' => env('key-********************'),
],
What is wrong with my settings and is there anything else you need to check? Please help I have been trying to study laracast for past 2 days but it doesn't send mail.
Your config is all messed up. This part in mail.php:
'driver' => env('mailgun', 'smtp'),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'arshaikh_17#hotmail.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
Should've stayed the way it initially was.
Then you change the configuration in the .env file in the project root. So if you have in your mail.phpthe following line:
'driver' => env('MAIL_DRIVER', 'smtp'),
Then in your .env file you can change the value of the property MAIL_DRIVER to mailgun.
In laravel 5.4 the mail part of my .env file looks something like this:
MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=postmaster#somelongstring.mailgun.org
MAIL_PASSWORD=verysecretstring
MAIL_ENCRYPTION=tls
MAILGUN_DOMAIN=somelongstring.mailgun.org
MAILGUN_SECRET=key-somelongstring
And I have not changed anything in the files in the config directory. The values for all of these variables you can find under your domain if you login to mailgun.
Also, read the documentation https://laravel.com/docs/5.3/mail or try to find a tutorial about setting up mailgun with laravel.
You should look at how to use environment configurations as described in the documentation:
When using the env() function, the first argument should be the name of the variable as defined in your .env file, while the second argument is the default.
Thus, in your config/mail.php and services.php you should be referring to variables which you have defined in your env() file as follows:
config/mail.php
'driver' => env('MAIL_DRIVER', 'smtp'),
'from' => [
'address' => env('MAIL_FROM_ADDRESS'),
'name' => env('MAIL_FROM_NAME'),
],
services.php
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
],
.env
MAIL_DRIVER=mailgun
MAIL_FROM_ADDRESS=arshaikh_17#hotmail.com
MAIL_FROM_NAME=Example
MAILGUN_DOMAIN=mydomain.com.pk
MAILGUN_SECRET=key-********************
Note that I often do not specify default values for, for example, your MAIL_FROM_ADDRESS since this will mostly vary from installation to installation. Further, you should never store API secrets like MAILGUN_SECRET in files like services.php which are often version controlled.
use their lib
install:
php composer.phar require mailgun/mailgun-php php-http/guzzle6-adapter php-http/message
include:
require 'vendor/autoload.php';
use Mailgun\Mailgun;
new object:
$mgClient = new Mailgun('YOUR_API_KEY');
See Example
https://documentation.mailgun.com/api-sending.html#examples
To me it was that I was using an incorrect value for MAILGUN_SECRET env variable, at first I was using a key that I received through email but the required value was the api secret key that is way longer. Api secret key can be found in: Settings -> API Keys -> Private API key at mailgun.org
This question already has answers here:
Laravel certificate verification errors when sending TLS email
(2 answers)
Closed 1 year ago.
I was unable to send an email in laravel 5,when I click send it return this message
ErrorException in StreamBuffer.php line 95:
stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Here is my .env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp-relay.gmail.com
MAIL_PORT=587
MAIL_USERNAME=**********#gmail.com
MAIL_PASSWORD=*********
MAIL_ENCRYPTION=ssl
file mail.php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp-relay.gmail.comt'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => null, 'name' => null],
'encryption' => env('MAIL_ENCRYPTION', 'ssl'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
];
I researched for hours but couldn't resolve this, any advice ?
P/S: I use Windows 10 and XAMPP for Webserver
Change in .env file:
MAIL_DRIVER=smtp to MAIL_DRIVER=mail
Here are two possible solutions:
1) Get rid of "tls" and leave MAIL_ENCRYPTION as blank.
2) If you are on MacOS Sierra and want to keep your 'tls' setting, type these two lines in your terminal/shall:
$ sudo mkdir -p /usr/local/libressl/etc/ssl/certs
$ sudo curl -o /usr/local/libressl/etc/ssl/cert.pem https://curl.haxx.se/ca/cacert.pem
The two lines basically help you create the default folder and import the latest certificate store from curl.haxx.se.
Here is the source article I got if interested: https://andrewyager.com/2016/10/04/php-on-macos-sierra-cant-access-ssl-data/comment-page-1/#comment-52
Hope it helps.
In your config file
the host should be smtp.gmail.com
From and name should not be null
change your mail encryption from ssl to tsl
dont forget to turn on less secure app in your google accout setting
Go to location \vendor\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php
at line 259 and comment the following:
//$options = array();
and add.
$options['ssl'] = array('verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true);
In forgot password laravel sends email which gives error like :
Swift_TransportException in AbstractSmtpTransport.php line 162:
Cannot send message without a sender address
i already have set my mail account details in .env and mail.php both.
My .env :
MAIL_DRIVER=smtp
MAIL_HOST=smtp-mail.outlook.com
MAIL_PORT=587
MAIL_USERNAME=raval_himanshu#live.in
MAIL_PASSWORD=pass
MAIL_ENCRYPTION=tls
and my mail.php is
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp-mail.outlook.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['raval_himanshu#live.in' => null, 'Himanshu Raval' => null],
/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/
'username' => env('raval_himanshu#live.in'),
'sendmail' => '/usr/sbin/sendmail -bs',
];
i have tried php artisan config:cache too but after that it gives same error.
i have made mistake in mail.php
'from' => ['raval_himanshu#live.in' => null, 'Himanshu Raval' => null],
that should be
'from' => ['address' => 'raval_himanshu#live.in', 'name' => 'Himanshu Raval'],
just try this code below, because this work for me
in .env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail#gmail.com
MAIL_PASSWORD=myAPPpassword_Generatedfromhttps://myaccount.google.com/security#signin
MAIL_ENCRYPTION=tls
in config/mail.php i change like this
'from' => ['address' => 'myemail#gmail.com', 'name' => 'Admin.com'],//default :'from' => ['address' => null, 'name' => null],
then run the php artisan config:cache to clear configurations cache and cache again with new configurations, i hope can help
Just run php artisan optimize:clear, its work for me.
you should do it in build function in your Mail which you created example is given below
public function build()
{
return $this->from('example#gmail.com')->view('welcome');
}
After .env update, please restart php artisan (CTRL+C then php artisan serve)