I wrote this code a couple of months ago. I used to be able to send email with the following configuration. But suddenly today, I am getting the following error.
Swift_TransportException in StreamBuffer.php line 265:
Connection could not be established with host localhost [Connection timed out #110]
This is the configuration from which I was able to send emails.
'driver' => 'smtp',
'host' => 'localhost',
'port' => 587,
'from' => ['address' => "test#xxx.com", 'name' => "test"],
'encryption' => 'tls',
'username' => 'test#xxx.com',
'password' => '*********',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
I have solved the problem. The configuration is wrong. I dont know why it worked earlier. But now I have followed the instructions from this link and now it is working.
Step 1 -> Go to "Email Account". You can find the icon at the home page of the cpanel.
Step 2 -> Click on the account next to the account you want to use. You will see a dropdown menu. There you will see an option saying "Configure Mail Client". Click on it.
Step 3 -> There at the bottom of the page you will find the proper settings. Look for outgoing server settings.
Related
This question already has answers here:
How to to send mail using gmail in Laravel?
(17 answers)
Closed 3 years ago.
I have been having this issue with Laravel email with Gmail and I have checked and reviewed so many questions on Stack Overflow but none still works in my case. I am using Laravel 5.4 and Xampp.
At first I thought it was my Xampp that cannot allow sending the emails but also when I move to the live mode(hosted it on a shared hosting) still have same issues there as well
But whenever I set the configuration to use Mailtrap, it's working and I know mailtap is just a development mail server, but whenever I use the Gmail it give me error such as "Expected response code 220 but got code "", with message """
Also when I try it on live mode it still gives same error.
My configuration file has the following
.env
MAIL_DRIVER=smtp
MAIL_HOST=gmail-smtp-msa.l.google.com (also tried smtp.gmail.com)
MAIL_PORT=587
MAIL_USERNAME=email#gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl
mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'gmail-smtp-msa.l.google.com'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => 'email#gmail.com',
'name' => 'Name Here',
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME', 'email#gmail.com'),
'password' => env('MAIL_PASSWORD', 'password'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
Hey here is the solution
MAIL_DRIVER='smtp
MAIL_HOST='smtp.gmail.com'
MAIL_PORT=587
MAIL_USERNAME='sample#gmail.com'
MAIL_FROM_ADDRESS='sample#gmail.com'
MAIL_FROM_NAME='Some Name'
MAIL_PASSWORD='XXXXX'
MAIL_ENCRYPTION='tls'
As well as the configuration on the Laravel side, you need to enable "Less secure apps" in your Gmail account.
On the Laravel side, this guide shows the settings you need. Use smtp.gmail.com for host, and either 465/ssl or 587/tls.
I am using Swiftmailer in Yii2 advanced and everything, this includes sending emails, works fine on my xampp server. But when I try it on my external Server (1&1 btw) I get a
Swift_TransportException
Connection could not be established with host
smtp.1und1.de [Connection timed out #110]
I already googled about it for hours an tried almost every solution including using gmail instead or using ports 465 and 25 with ssl and tls. Also using IP-Adress instead of hostname.
I feel like there could be a firewall or some email options I miss but I have tried everything I can think of.
My code looks like this:
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '#common/mail',
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.1und1.de',
'username' => 'mymail#myadress.de',
'password' => 'mypassword',
'port' => '587',
'encryption' => 'tls',
],
],
and again, works perfectly fine on localhost.
Maybe someone has an idea what I am doing wrong?
I've configured to gmail SMTP server to send email. Account less secure app turned ON, also Recapture thing enabled. Here is the mail.php configuration.
This code working fine on hostgator server. But we have another server, mails are not sending from that server. What should I do now?
Error image
http://screencast.com/t/BSCurEEubPJV
return array(
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => array('address' => 'xxx#gmail.com', 'name' => 'xxxxTeam'),
'encryption' => 'tls',
'username' => 'xxx#gmail.com',
'password' => 'xx#123',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
);
I got the same issue. Finally found that my server IP address was blacklisted.
Please check your IP address using this link.
Link : https://mxtoolbox.com/blacklists.aspx
If it is blacklisted, send re-list request via they provide links. That's it
Thank you
I am trying to send a mail to my email-id. I have followed all the steps that might required to send a mail.
But it keeps on coming 2 errors
Connection could not be established with host smtp.gmail.com [A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.#10060]
Maximum execution time of 30 seconds exceeded.
my controller is
public function contact()
{
Mail::send('clientinfo.contact',['name' => 'shweta'],function($message){
$message->to('myemail#gmail.com','Some Name')->subject('Welcome!')->from('otheremail#example.com');
});
mail.php file :
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => 'someone#example.com', 'name' => 'Some One Sender'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
Please help me through this.
Make sure you install Guzzle to your project by adding the following line to your composer.json file:
"guzzlehttp/guzzle": "~5.3|~6.0"
and editing your .env file with real email-id and password. Also, enable, less secure apps for that email-id as told by #Bharat Geleda
then your above code will run properly.
This is what I did.
I enabled two step verification on may gmail account
created separate apps password for my app here (screenshot below) (https://security.google.com/settings/security/apppasswords)
I that password into my laravel .env file and it worked.
screenshot
just select "Other(custom name)" on the "select app" and it will generate a password for you.
Use the MAIL_PORT=587 instead of the default mail_port in your .env file.
I'm develop a website using Laravel 4.1. I config my email system and send email successfully on built-in server localhost:8000. But when I host the web on a shared hosting, it always tell: Swift_TransportException
Failed to authenticate on SMTP server with username "email#domain.com" using 2 possible authenticators
I don't know what the reason is? I've search on this site but no solution works.
return array(
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => array('address' => 'email#gmail.com', 'name' => 'Test email'),
'encryption' => 'ssl',
'username' => 'your_gmail_username',
'password' => 'your_gmail_password',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
);
I also used my our domain's email but it doesn't work neither. Hope for help.
In my case, I had a Cpanel dedicated server. My host informed me that exim mail server was failing and restarting a couple times a day.
It looked like all connection threads were being used up and then locked until it restarts.
My host added another 100 connection threads to the pool. Most probably this help you as well.