Laravel Illuminate\Support\Facades\Mail is not sending mail - php

I have multiple websites that contain a function that sends emails, the websites are hosted on AWS Linux hosting and I'm using cPanel.
an issue with sending emails started today, it stopped sending emails from all of the websites, I tried changing the function and several other things but nothing worked, and I don't see any errors in the error logs of the websites.
I'm using the following to send the emails:
Illuminate\Support\Facades\Mail
here's the function in the email controller:
Mail::send(['text'=>'Mail.name'],$data, function($message) use ($hostName) {
$message->to('TO EMAIL ADDRESS')->subject('subject');
$message->from(config('mail.from.address', ''),$hostName);
});
here's .env email configuration:
MAIL_DRIVER=sendmail
MAIL_HOST=mail.domain.com
MAIL_PORT=587
MAIL_USERNAME=[hidden]
MAIL_PASSWORD=[hidden]
MAIL_ENCRYPTION=''
I tried using smtp driver, port 465, nothing worked.
the from email I'm using is a cPanel email.
I'm using laravel 9 and PHP 8

Related

Error code 450 Requested mail action not taken: mailbox unavailable when send email laravel

I want to send email to user. I have created using gmail smtp setting and it's working normally but when I tried send email using yahoo smtp setting it's not working and show error code like below
Swift_TransportException (450)
Expected response code 250 but got code "450", with message "450 Requested mail action not taken: mailbox unavailable "
I've cache config laravel using php artisan config:cache but it's still not working as normal as gmail settings
Here's .env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mail.yahoo.com
MAIL_PORT=587
MAIL_USERNAME=xxxx#yahoo.com
MAIL_PASSWORD=xxxx
MAIL_ENCRYPTION=tls
Do you know if there's any settings that I forgot ?
Thank you
try restart your server and try again and also show your credentials in your env file.
Probably you need to enable below option from your yahoo account:
Account Security -> Allow apps that use less secure sign in

Laravel stopped sending email (mandrill account)

This code was working fine previously and laravel abruptly stopped sending mail since last week. I tried to send mail using swiftmailer separately with same credentials which is also working fine. I have following credentials on .env file for mail functionality in laravel-
MAIL_DRIVER=mandrill
MAIL_HOST=smtp.mandrillapp.com
MAIL_PORT=465
MAIL_USERNAME=*******
MAIL_PASSWORD=*******
MANDRILL_SECRET=*********
MAIL_ENCRYPTION=ssl
I configured /config/services.php and /config/mail.php files to.
There is no error in Mail::failures().
what could be the possible reason for such problem.
I can send mail with templates using swiftmailer but it's necessary to figure-out the problem to fix such problems with no time in future.

mail is not coming from my hosting server after migration to gmail

My PHP script sending mail to all other mail perfectly, but not getting any mail in trustmedi.com. Ff I send mail from my gmail to dummy#trustmedi.com, it's working. I had already tried gmail smtp, PHPmailer but it's not working. My dummy.trustmedi.com is using gmail server.
from my previous post I have got following answer
The main reason is that your domain is listed on SORBS DUHL black list which says:
Additional Information: [Dynablock] Dynamic IP address, use your ISPs
mail server Listed but has active as exception(s) and therefore might
NOT be blocked.
166.62.27.124 is an active exception for the network 166.62.24.0/22.
166.62.27.151 is an active exception for the network 166.62.24.0/22.

Expected response code 250 but got code "", with message ""

I can send my emails in localhost flawlessly. but ever since I uploaded my program into a hosting site I get this error
Expected response code 250 but got code "", with message ""
I also updated the .env file.
MAIL_DRIVER=smtp
MAIL_HOST=smtp-mail.outlook.com
MAIL_PORT=587
MAIL_USERNAME=email#outlook.com
MAIL_PASSWORD=123456789
works in localhost but not in the hosting site.
i am using laravel 5
I ran through this error so many times for some reasons.
When see this error,
Expected response code 250 but got code “”, with message “”
Please triple check your email password.
Note :
Test your credentals first on a phone app or log-in into the mail site.
If pass, you may update in your .env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mail.yahoo.com
MAIL_PORT=465
MAIL_USERNAME=dev.bheng#yahoo.com
MAIL_PASSWORD=****
If you know for sure that your password is correct.
Check to make sure your Gmail or Yahoo Mail allow app log-in.
Example
Yahoo
we solved this problem by clearing the Laravel's configuration cache
php artisan config:clear
looks like the smtp was blocked for hostinger free users.
http://www.hostinger.ph/forum/news-and-announcements/229-email-service-updates-1.html
This one worked for me, 'if you are using GMAIL'
Go to 'My Accounts'
Go to 'Sign-in & security'
Scroll down to 'Allow less secure apps'
Switch #3 to ON
After doing this and if you just recently set up your email configurations on laravel and still doesn't work, try running:
php artisan config:cache
I've a working laravel swiftmailer using google server. Here my steps:
I visited the link
https://www.google.com/settings/security/lesssecureapps and turned
on less secure apps.
I edited .env file as like below:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=username //i.e. username#gmail.com
MAIL_PASSWORD=password //Gmail accounts password
MAIL_ENCRYPTION=ssl
Edit username and password with your own.
In my controller, I wrote the following code:
$rawData = request::all();
Mail::queue('program.meeting.emailInvite', $rawData, function($message) use ($rawData)
{
$message->from('info#echosofts.com', 'Echosofts')->to(array_map('trim', explode(',', $rawData['all_email_id'])))->subject($rawData['mail_title']);
});
Then email was working fine except the sender email ID was my google account (username#gmail.com) instead of info#echosofts.com.
To overcome the sender email changing problem, I visited my google account and did the following:
"Setting icon"-> Settings -> Accounts and Import->Send mail as->Add another email address your own.
The following settings depends on your configuration.
Email address: info#echosofts.com
SMTP server: mail.echosofts.com
Username: info#echosofts.com
password:**********
Port:25
FWIW - I get this error when sending a email with an empty string in the to field.
in "mautic" (CRM), if you mail to a large amount of contacts, like more than 10k this occurs. The real reason is mostly a wrong configuration in php settings. For example:
max_input_time = 60
Will only let your server run the script for 60 seconds, try a higher value.
PHP configuration depends on your server and its installed software, mostly configured by htaccess or php.ini file.

Swiftmailer working on localhost but not in production

On my localhost (Linux Mint OS) Swiftmailer is working fine with the following code, but whenever I move it up to my server is just hangs at the send function and then gives me an internal server error.
I currently have my email setup through Google Apps, so maybe SMTP will not work for this situation? If thats the case, how do you suggest I change this from SMTP.
Also, whenever I send an email like this, it is showing up with a from address of the one in the username area. I want it to show up with the from address in the "setFrom" function.
//Include the swiftmailer class
require_once 'comm/swiftmailer/swift_required.php';
//Create a message
//Pass it as a parameter when you create the message
$message = Swift_Message::newInstance();
$message->setSubject('My Subject');
$message->setFrom(array('noreply#domain.com' => 'No Reply'));
$message->setTo(array('me#domain.com' => 'Me'));
$message->setBody($emailContent, 'text/html');
//Create transport class and email the message
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')->setUsername('useracctname')->setPassword('password');
$mailer = Swift_Mailer::newInstance($transport);
$result = $mailer->send($message);
Thanks a lot for any help!
This might be a port problem on the server. Port 465 could be closed to prevent spamming. It could also be that the server's version of PHP lacks SSL support.
I am wondering though, could it be that I am not using the local mail server so it wont allow SMTP?
If you address gmail as explicitly as you do, it's very unlikely you're using another transport type or a different server.
Also, what about using one of the other transport types?
I think SMTP is your only option to get it running with Gmail. It could, however, be that your server is providing a mail() based service (obviously with a different sender address than GMail though). In that case, you may be able to use Swiftmailer's mail transport.
I had the same problem : I was able to send gmail email in local (after updating that configuration : https://www.google.com/settings/security/lesssecureapps ) but not in production.
To fix my problem I've logged to my gmail account with my production ip / from my production server and answer the gmail security question.
One of the solution to log to your gmail account with your production ip, is to
open an ssh tunnel (ssh -2NfCT -D 5000 yoursshuser#yourdomain.org)
configure you browser to use that proxy (eg Firefox :to Preferences > Advanced > Network > Settings > Manual proxy configuration > SOCKS Hosts: localhost / Post: 5000 / SOCKS v5 )
log to you gmail account as usual
The error outputed by Symfony was :
app.ERROR: Exception occurred while flushing email queue: Failed to authenticate on SMTP server with username "joe.doe" using 1 possible authenticators [] []
well, here is the solution.
if you are sending SMTP mail you should create email account at the server then use this email info at your code.
the server will not send the email if you don't have valid email account to send using it
when you use "from".
this should be a true correct email account a fake one.
the only possible reason to send using fake account is using mail() function.

Categories