I can send email in my localhost, but when I put it in our remote server I get this error:
I don't know what the problem is. Anyone?
I used the laravel default mail driver which is swiftmailer.
Check your gmail: in settings, enable access for less secure apps and it will work.
Related
I have this error when I try to send mail with Laravel 9 app using Gmail:
Failed to authenticate on SMTP server with username "*************#gmail.com" using the following authenticators: "LOGIN", "PLAIN", "XOAUTH2". Authenticator "LOGIN" returned "Expected response code "235" but got code "534", with message "534-5.7.9 Application-specific password required. Learn more at 534 5.7.9 https://support.google.com/mail/?p=InvalidSecondFactor h4-20020a056830034400b0060603221274sm8631029ote.68 - gsmtp".". Authenticator "PLAIN" returned "Expected response code "235" but got code "534", with message "534-5.7.9 Application-specific password required. Learn more at 534 5.7.9 https://support.google.com/mail/?p=InvalidSecondFactor h4-20020a056830034400b0060603221274sm8631029ote.68 - gsmtp".". Authenticator "XOAUTH2" returned "Expected response code "235" but got code "334", with message "334 eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ==".".
This is my .env configuration.
MAIL_MAILER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=************#gmail.com
MAIL_PASSWORD=************
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=************#gmail.com
MAIL_FROM_NAME="Claims - *****"
I've been reading, and apparently since 5/22/2022 you can no longer activate the option to allow access to less secure applications in Gmail... so, how can we solve this? is this really my problem or another?
google recently changed there security protocol about less secure apps, that's why it's showing the error.
I'm running Laravel 6.20.0 and I'm experiencing the following error since yesterday when my queue worker is trying to send an email:
Swift_TransportException: Expected response code 250 but got an empty response in public_html/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:448
I've tried requeuing my emails several times now since yesterday, but I keep on receiving the same error when it attempts to send. This worked flawlessly before for almost a year, so I'm a bit confused what is causing this issue. I haven't changed any credentials nor changed any code or configuration recently.
My mail settings are as follows:
MAIL_DRIVER=smtp
MAIL_HOST="smtp-relay.gmail.com"
MAIL_PORT=587
MAIL_USERNAME="my#user.name"
MAIL_PASSWORD="myapppassword"
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="my#from.address"
MAIL_FROM_NAME="My Name"
I've doubled checked in my Google Admin that both the IPv4 address as well as the IPv6 address of my server are whitelisted and the SMTP relay service is enabled. I also created a new App password within my Google account to see if that would fix the problem - but no luck there.
I've also cleared the config cache (and have tried php artisan config:cache) and tried restarting supervisor which runs the worker running the task for the email queue. I've also tried requeueing the emails one by one in case I triggered some kind of throttling, but to no avail. By no means is my website sending many emails, about a 100 a month, well within the limits posed by my email account. (And I currently got <10 stuck in queue.)
As a last resort I turned off SMTP verification and TLS encryption in the Google Admin, so the only requirement for using the SMTP was having the IP address whitelisted (which it is). But this didn't work either, so I've switched SMTP verification and TLS encryption back on again as a requirement.
Finally; I ran a composer update, but that didn't fix the problem either.
I've found some other older threads on Stackoverflow with a similar problem, but I had already tried all offered solutions as described above.
What am I missing?
i think you need change mail port to 25 like this :
MAIL_PORT=25
Just faced same issue.
In my case SMTP sending worked when I tried to send an email without queues.
But when I tried to send same email with same config using queue, I got error that looks like:
[2021-02-15 12:43:24] local.ERROR: Expected response code 250 but got an empty response {"exception":"[object] (Swift_TransportException(code: 0): Expected response code 250 but got an empty response at /app/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:448)
[stacktrace]
#0 /app/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(345): Swift_Transport_AbstractSmtpTransport->assertResponseCode('', Array)
#1 /app/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(305): Swift_Transport_AbstractSmtpTransport->executeCommand('HELO [127.0.0.1...', Array, Array, false, NULL)
#2 /app/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(368): Swift_Transport_EsmtpTransport->executeCommand('HELO [127.0.0.1...', Array)
#3 /app/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(341): Swift_Transport_AbstractSmtpTransport->doHeloCommand()
#4 /app/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(148): Swift_Transport_EsmtpTransport->doHeloCommand()
After long research I've found that issue is related with HELO command itself.
As you can clearly see in the log, for some reason (probably server hostname) there is 127.0.0.1 IP address, which Google is blocking.
How I resolved that:
So to resolve that, I've added one little line in my artisan file:
$_SERVER['SERVER_NAME'] = 'mydomain.com';
So my artisan file looks like this now:
#!/usr/bin/env php
<?php
$_SERVER['SERVER_NAME'] = 'mydomain.com';
define('LARAVEL_START', microtime(true));
...
Spoke with Google Workspace rep
As a temporary solution they asked to use
smtp.gmail.com instead of smtp-relay.gmail.com
Worked on 2 of our projects.
P.S. The limit is 130 emails per account on Workspace (former Gsuite)
for example if you have 5 users, 5x130=650
What the rep said haha :)
I am using Exim mail server for my smtp and experiencing an issue when sending emails from the server if the connection is instantiated from within the server. However if I try authenticating from outside, emails are sent without any problems. Am using Laravel which ships with Swift mailer. This is the error laravel is giving out.
production.ERROR: Expected response code 250 but got code "550", with message "550 127.0.0.1 is _my_ address
Exim's log also has a similar error;
H=localhost [127.0.0.1] X=TLSv1:ECDHE-RSA-AES256-SHA:256 CV=no rejected MAIL <no-reply#mydomain.com>: 127.0.0.1 is _my_ address
My .env file has credentials set up correctly as follows
MAIL_DRIVER=smtp
MAIL_HOST=mydomain.com
MAIL_PORT=587
MAIL_USERNAME=no-reply#mydomain.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
The code used to send the emails is as below;
Mail::to('admin#mydomain.com')->send(new AlertEmail($information));
What am wondering is,could the problem be caused by trying to send the email to addresses within the same domain? I hope someone can help me out. Am almost going crazy.
NB: Roundcube is sending emails fine.
I'm encountering this error after hooking up SparkPost and Laravel. I only want to deploy this application locally for development purposes (localhost). And I don't have any domain at the moment. Does this error have to do with domain setup? Thanks and guide me please.
The error I'm seeing is this:
Client error: POST https://api.sparkpost.com/api/v1/transmissions
resulted in a 400 Bad Request response: { "errors": [ { "message":
"Invalid domain", "description": "Unconfigured Sending Domain
", "code": "7001" (truncated...)
Refer to the image to find how to add a sending domain. After adding, please verify it.
As you said you only want to send email for development, you can use a simple smtp or even the native php mail driver provided by laravel. With Parkpost API, you definitely need a working domain name.
If you don't want to use built in Laravel mail facade then you can use beautymail package.
Here is the link for all supported email packages - http://packalyst.com/packages/tag/email
Go for the maximum downloaded package ex - beautymail package
Can any one tell me why I'm getting this error with codeigniter when it comes to sending mail.
some time it work fine some times i get this error
451 Please try again later
The following SMTP error was encountered: 451 Please try again later
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
Are you sure your SMTP server is working fine at the time you get this error? If it works sometimes, then that means that your configuration is probably fine. I'd deploy the code of a test server online and then run your code to see if its really a configuration problem or maybe a problem with the SMTP host that you're trying to send the mail through.