reset password works on localhost and not on web host - php

I'm working on a laravel project (maintenance of an existing project).
The reset password was not working.. I fixed the issue by changing the .env file on my localhost.
It was
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
I changed it to
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=email#mailtrap.io
MAIL_PASSWORD=the password
MAIL_ENCRYPTION=null
It works fine on my localhost.. When I change the .env.example on bitbucket it still doesn't work and gives me the same error
Swift_TransportException in AuthHandler.php line 181:
Failed to authenticate on SMTP server with username "noreply#igpastpapers.com" using 2 possible authenticators
Any ideas?

Make sure you change your .env file in your production code, NOT your .env.example file. The .env.example is only setup so you can see the build of your .env file wherever you keep your version control code (Git, etc), without actually having the secure data shown. Check this link out:
Environment Configuration

Related

Laravel: Swift_TransportException: Connection could not be established with host

Can't send email from Laravel platform. Tried with different another emails (gmail, mailgun) and they work properly but it seems that can't make it work with the one our customer wants to use:
MAIL_DRIVER=smtp
MAIL_HOST=xxx.xxx.xx
MAIL_PORT=25
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
We got this error:
Swift_TransportException: Connection could not be established with
host [php_network_getaddresses: getaddrinfo failed: Name or service
not known #0] in
.../vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:269
I can connect with telnet from the server so it apparently everything's ok. But I find very weird this configuration. Do I need to check something else in Laravel to make it work?
EDIT 1:
Tried with this configuration too:
MAIL_DRIVER=smtp
MAIL_HOST=xxx.xxx.xx
MAIL_PORT=587
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=TLS
Keep getting the same error,tho
Uhm, for some reason (I don't really know why) .env file does not apply changes even with config:clear or config:cache...so everytime I changed something there I always get the same error.
The only solution was to do a sudo reboot and then it gets the new configuration.
this can be the case if a proxy is used on the Internet. check without using a proxy

Configuring a mail driver in Laravel (using MAMP)

I'm trying to use Laravel's auth package, and I'm getting various errors when trying to use its "send password reset link" option. I'm using MAMP as the server. My .env by default looks like this:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
I keep getting Swift_TransportException errors when I try to send mail.
Am I supposed to connect a Gmail address I own, using my email and password, essentially telling Laravel to use Gmail as the mail server? Isn't this a security risk since my password would be out in the open?
As an alternative, can/should I add a mail server to MAMP and use its credentials? Again, isn't that a security risk?
This configuration will save emails to log file:
MAIL_DRIVER=log
MAIL_HOST=mailtrap.io
MAIL_PORT=587
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=tls
If you register in Sendgrid, you will be able to use their smtp server.
This configuration will use Sendgrid as smtp Server:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=your_user_name_from_sendgrid
MAIL_PASSWORD=your_password_from_password
MAIL_ENCRYPTION=tls

Laravel .env file example for godaddy

I am trying to use my project on godaddy but it is constantly giving me an error:
SQLSTATE[28000] [1045] Access denied for user 'nagesh'#'ip-address of
the website' (using password: YES) (SQL: select * from admins where
email = admin limit 1).
Although my credentials should be correct as they are created in the godaddy cpanel but still I am having this error. I searched a lot on stackoverflow and tried many solutions but nothing seems to be working. This is my .env file:
APP_ENV=local
APP_KEY=base64:Qx5MJdayISVHcd5p9nW0zJvb4BC6jyWD9BySf4j8yis=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST="IP address of the website"
DB_PORT=3306
DB_DATABASE=ncminsti_ncm
DB_USERNAME="username i created using the cpanel's add new user form"
DB_PASSWORD="password created with above user."
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
I believe am doing some mistake in my .env file. Probably the DB_Host field is wrong. I am new to laravel and not sure what should be the correct configuration for .env file. Please help me in connecting to the DB. Thank you.
If website and database are on the same server, then:
DB_HOST=127.0.0.1
You will need to try and connect to your database first:
mysql -h <thehost> -u <theuser> -p
This will either ask you to type your password or report an error. Since Laravel could not connect to your database (ultimately generating something like the above), it is safe to assume that the command above will fail. You will need to find out what the problem is, solve that and then apply the solution to your Laravel environment as well.
It is very possible that you had a typo in the username/password or defined your hostname incorrectly. It is possible that you just need to connect to localhost (127.0.0.1), but it's also possible that the server is located either on a remote computer or an image (like a Docker image). You may also need to connect to a VPN or whitelist your IP address. Try contacting your sysadmin to find out how you can connect to your database on the Command-Line Interface and once that works, apply the same idea in your Laravel config.

Connection to tcp://smtp.mailtrap.io:587 Timed Out

I tried loading my page I created using laravel and after I hit the registration button and I got the above error message, please what must I do?
Mailtrap is an email testing service for testing. It will catch all the mail sent from your application, so you can test mails without sending it to client. In order to use it, you have to follow these steps:
First you have to create an account on Mailtrap. Then go to your dashboard and note your credentials. It may be something like:
Username: 05921688469af01
Password: 2efe39296ae5b7f
Then paste this values in your .env file of your Laravel application (the username must be pasted in MAIL_USERNAME and the password must be pasted in MAIL_PASSWORD).
It might look like this:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=05921688469af01
MAIL_PASSWORD=2efe39296ae5b7f
MAIL_ENCRYPTION=null
Then try again and it will work! You can go to your Mailtrap dashboard to see the result.
Check below settings if you are using in your .env file of root folder of project.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.yourdomainname.com
MAIL_PORT=2525
MAIL_USERNAME=email#yourdomainname.com
MAIL_PASSWORD= ********
MAIL_ENCRYPTION=null
Or
if you are using Gmail for sending a email then do following settings.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=******#gmail.com
MAIL_PASSWORD=*****
MAIL_ENCRYPTION=ssl
Try to use another SMTP port (2525, 465 or 25) https://mailtrap.io/faq#faq14
And also make sure to set your credentials which you got from mailtrap in .envfile
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=your mailtrap username
MAIL_PASSWORD=your mailtrap password
MAIL_ENCRYPTION=null

Could not Reset password using Laravel 5.3.4

I'm new to php/laravel tech.
My .env file contains following configuration[1];
When I try to reset the password, It says, password link has been sent, But I haven't received any emails.
What I'm doing wrong here?
p.s: I'm providing null for MAIL_ENCRYPTION/ MAIL_USERNAME, due to one issue I faced.(Swift_TransportException Failed to authenticate on SMTP server with username "abc#abc.com" using 2 possible authenticators)
[1]
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=2525
MAIL_ENCRYPTION=null
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_FROM_ADDRESS=abc#abc.com
MAIL_FROM_NAME="Administrator"

Categories