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..
Related
I am trying to find out why this happens.
.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=*******t#gmail.com
MAIL_PASSWORD=******
MAIL_ENCRYPTION=tls
mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => '******#gmail.com', 'name' => 'Project'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('******#gmail.com'),
'password' => env('******'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
];
This is the error
Failed to authenticate on SMTP server with username "" using 3 possible authenticators. Authenticator LOGIN returned Swift_TransportExce ▶
534-5.7.14 GVHg3-rU8SDpVLdwnIPviBCjKNnBRcxuU2N3-pcUWd0TeMbM_vULrHhQcVNXjhoewjrquW\r\n
534-5.7.14 Jttd6jNXfnledZiAMv-rjMvpnd01nas-2J2BYU_Krd4kzT-YmTR_HW9uW3S6Ts2jUxDaC8\r\n
534-5.7.14 XmT_TV9QqYXHXkTMcrX3OG9D4QyF4E6w7fwnu2bYZT36rZXTU-HqJwlWzJBv8-MC2P9xrN\r\n
534-5.7.14 cUd4-BirG0rfAjlDxy5bkbon3S_bIFSZQVd0-5wskctUR4do7F> Please log in via\r\n
534-5.7.14 your web browser and then try again.\r\n
534-5.7.14 Learn more at\r\n
534 5.7.14 https://support.google.com/mail/answer/78754 l5-v6sm1366079wrv.84 - gsmtp\r\n
" in C:\xampp\htdocs\wer\walrer\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php:457\n
Stack trace:\n
I checked email credentials and they are the same. In this project I
have used authentication , but can't find a solution to this one.
I think there is something wrong with your mail.php file.
You should be passing the variable names to the env() function for username and password.
So this:
'username' => env('******#gmail.com'),
'password' => env('******'),
Becomes this:
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
Your .env file looks good.
You mail.php file should look like this:
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => '******#gmail.com', 'name' => 'Project'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME', '******#gmail.com'),
'password' => env('MAIL_PASSWORD', '******'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
];
The value in the second parameter for the env() function, gets used if the .env key specified in the first parameter is not found.
You need to enable less secure apps access at your google account for this to work
I develop a laravel app and I want to automatically send emails with remainder to users.
I created command like in this article. But I get this error:
[Illuminate\Contracts\Container\BindingResolutionException]
Unresolvable dependency resolving [Parameter #0 [ <required> $config ]] in
class RollbarNotifier
This is my code:
.env
MAIL_DRIVER=smtp
MAIL_HOST=example.com
MAIL_PORT=465
MAIL_USERNAME=noreply#example.com
MAIL_PASSWORD=PAssWord
MAIL_ENCRYPTION=SSL
MAIL_FROM_ADDRESS=noreply#example.com
MAIL_FROM_NAME="FROM FROM"
ROLLBAR_TOKEN=<my_token>
config/mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'example.com'),
'port' => env('MAIL_PORT', 465),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'noreply#example.com'),
'name' => env('MAIL_FROM_NAME', 'FROM FROM'),
],
'encryption' => env('MAIL_ENCRYPTION', 'SSL'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
It looks like your dependency injection is not working. It is missing a configuration file.
I am not sure which package you are using. But when I look at the installation manual at https://github.com/jenssegers/laravel-rollbar I see you also have to add some configuration in the services.php:
'rollbar' => [
'access_token' => env('ROLLBAR_TOKEN'),
'level' => env('ROLLBAR_LEVEL'),
],
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 *******.
I'm trying to use the auth forgot password functionality but it's not working. I already turned on the access for less secure apps in gmail.
.env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.io
MAIL_PORT=587
MAIL_USERNAME=myemail
MAIL_PASSWORD=mypass
MAIL_ENCRYPTION=tls
mail.php
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello#example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
This can be caused by the security settings on your Gmail account.
Probably you need to set the allow less secure apps to access your account.
You can read here how to do it: https://support.google.com/accounts/answer/6010255?hl=en
Also as an SMTP server use smtp.gmail.com
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