Throughout my Laravel 5.4 codebase, I am using Amazon SES to send email:
Mail::to('myemail#example.com')->send(new App\Mail\MyEmailClass);
Not a problem. Except I am working in a team, and I test email a lot. I want to use Mailtrap.io for testing emails rather than spamming my own account(s).
To configure Mailtrap with PHP/Laravel, I am required to use the SMTP driver and Mailtrap SMTP host, and port:
return array(
"driver" => "smtp",
"host" => "smtp.mailtrap.io",
"port" => 2525,
);
My driver is currently set to use SES.
How can I use multiple drivers: SES and Mailtrap?
I dont know if you still facing this problem...Instead of you change "mail.php" inside the "config" directory, why not considering insert this in ".env" file entering the following parameters:
MAIL_DRIVER = smtp
MAIL_HOST = smtp.mailtrap.io
MAIL_PORT = 465
MAIL_USERNAME = "get this on mailtrap settings"
MAIL_PASSWORD = "get this on mailtrap settings"
MAIL_ENCRYPTION =
Related
I'm trying to send emails from Laravel app that I have in production, but it's not working.
It gives me this error:
Connection could not be established with host smtp.googlemail.com :stream_socket_client(): unable to connect to ssl://smtp.googlemail.com:465 (Connection timed out)
But when I try to send email from localhost it works correctly.
my config mail
MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=*********
MAIL_PASSWORD=**********
MAIL_ENCRYPTION=ssl
also email is less secure:on
did you tried it out?
Using gmail smtp via Laravel: Connection could not be established with host smtp.gmail.com [Connection timed out #110]
Also make sure your if your gmail account has 2 factor authentication enabled or not.
If there is any two factor authentication enabled in your account then you can use App specific password from google account page.
There are lots of services you can use like Sendinblue, sendgrid etc.
I have successfully configured the smtp connection on local but when i am using it on live go-daddy its throwing e error that connection has been refused.
$smtpOptions = new \Zend\Mail\Transport\SmtpOptions();
$smtpOptions->setHost('smtp.gmail.com')
->setConnectionClass('login')
->setName('smtp.gmail.com')
->setConnectionConfig(array(
'username' => 'XXXXXX#gmail.com',
'password' => 'XXXXX!',
'ssl' => 'tls',
))
->setPort('465');
$transport = new \Zend\Mail\Transport\Smtp($smtpOptions);
i have tried port 587 also. Would be great if someone could guide me how to solve this . Stuck over this from few days . thanks
See configuration of your godaddy mail server. I use following host for godaddy account -
mail domain: smtpout.secureserver.net
host: 173.201.193.101
port: 25
Above configuration works fine for me. Please use your own username and password that is not mention here. Also I use SMTP for mail transport.
I want to send emails from my Laravel application but I'm getting this error:
Swift_TransportException in StreamBuffer.php line 268: Connection could not be established with host gnom.websitewelcome.com [ #0]
This is my .env file:
MAIL_DRIVER=smtp
MAIL_HOST=gnom.websitewelcome.com
MAIL_PORT=465
MAIL_USERNAME=mymail#hssoluciones.com
MAIL_PASSWORD=mypass
MAIL_ENCRYPTION=ssl
And I'm testing from my web.php file like this:
Route::any('mail', function() {
$cliente = Auth::user();
Mail::send('backend.emails.bills',
[
],
function ($m) use ($cliente) {
$m->from('mymail#hssoluciones.com', 'My Name');
$m->to('someones#mail.com', 'Title')->subject('Foo subject');
});
});
I've tried everything I've read from the differents posts online but I'm getting the same error...
Can someone help me?
This is not an issue within Laravel or your usage of the Swift Mailer. PHP is unable to connect to the SMTP server to deliver the emails. You should one see if you are able to connect to the SMTP server using your local machine. If not, then there is the issue. If you are able to connect then ensure that there is not any firewall blocking that on the server or whitelisting of IPs on the SMTP server side.
Hi I setup a contact form for my website with following configuration using Laravel framework
MAIL_DRIVER=smtp
MAIL_HOST=smtp.netregistry.net
MAIL_PORT=465
MAIL_USERNAME= example#domain.com
MAIL_PASSWORD=******
MAIL_ENCRYPTION=ssl
MAIL_FROM= example#domain.com
MAIL_NAME= name
the above config works fine in my localhost, however when I tried in live server it gives me error
Connection could not be established with host smtp.netregistry.net [Connection refused #111]
I tried to fix it by changing mail server to smtp.gmail.com and even tried port 25, 465, 587 for encryption such as ssl, tls, startTLS none of them worked.
So I contacted hosting providers and asked for help and after 12 days of my struggle to get them address my issue finally come up with
our cloud infrastructure does not allow external smtp connections from our hosting. This means that if you are sending emails from your website you will need to use localhost as the smtp host setting.
so now I tried to change my MAIL_HOST to localhost which gave me error
Connection could not be established with host smtp.netregistry.net [Connection refused #0]
and now they were suggesting something wrong with my script. Any suggestions
That is complete BS from your host. First thing, it's common for cloud systems to block OUTGOING SMTP, as it's a spam prevention measure, but your script is fine. Your host may be blocking everything but port 80, which means you can't connect to an SMTP host at all. You may be able to use localhost by not using SMTP at all, and use the builtin mailer(sendmail is common).
Change MAIL_DRIVER=smtp to MAIL_DRIVER=mail to use php's built in mailer. This may solve your problem, if not, then you should seek other hosting arrangements.
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.