Laravel - Connection could not be established with host smtp.gmail.com - linux

I've tried all the possible solutions available here in stackoverflow, however nothing... I think the problem is related to the firewall, I can send mail using SMTP gmail on my local machine, but not in my server, I get the following message:
Connection could not be established with host smtp.gmail.com [Connection timed out #110]
I've tried the following commands:
ufw allow 587/tcp
iptables -I OUTPUT -p tcp --dport 587 -j DROP
iptables -I OUTPUT -d smtp.gmail.com -p tcp -m tcp --dport 587 -j ACCEPT
iptables -L OUTPUT -n
However not worked...
This is my .env email settings:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=*****#gmail.com
MAIL_PASSWORD=*****
MAIL_ENCRYPTION=tls
My controller for sending emails:
public function postEmail(PostEmailRequest $request)
{
if ($request){
Mail::send('app.pages.contato.email', $request->all(), function($message) use ($request)
{
$message->from($request->email , config('settings.website_title'));
$message->to(config('settings.admin_email'))->subject($request->assunto);
});
return redirect('contato');
}else{
return redirect('contato')->withErrors($request);
}
}

I sent a ticket to Digital ocean and that is the obtained answer:
Hello!
To curb a recent increase in abuse and SPAM, we have an initial SMTP block on new accounts created in certain contexts.
To remove that block we'd like to do some manual account verification.
Please let us know the following:
Your Name
Location
Phone Number
The reason you are requesting the removal of the SMTP block
Also, please provide as many of the following as you can to help us verify your identity:
Your public Twitter handle
Your blog
Your company or personal website
Your public Facebook profile
We take SPAM very seriously as we comply fully with the CAN-SPAM Act. If you're not familiar, this says that you may not send bulk email unless you maintain a double-authorized list of subscribed members including IP addresses and relevant contact information. Also, you must follow guidelines for including removal links with all sent emails according to the CAN-SPAM Act.
If you have any questions we're happy to help answer them for you.
Regards,
DigitalOcean Support
Edit
I replied with the information that was requested and now everything works perfectly =)

Have you tried the following:
.env:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=username#example.com
MAIL_PASSWORD=pass
and mail.php:
'encryption' => 'ssl',

You need to enable access for less secure applications google
https://www.google.com/settings/security/lesssecureapps

First of all check in gmail account if it allow to send email less secure apps.
https://support.google.com/accounts/answer/6010255?hl=en

Try to activate your account app password
https://accounts.google.com/b/0/DisplayUnlockCaptcha
To learn more: https://accounts.google.com/UnlockCaptcha

I had similar issue with my laravel 5.3 app. My error was with self signed certificate on server. Solution here - https://stackoverflow.com/a/41267848
add to your config/mail.php this code somewhere
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],

Related

Send email via GMail SMTP in REBOL 2

I am new to REBOL. People blogging about how great REBOL is used sending an email as an example, similar to this example from the "send" documentation:
send luke#rebol.com "Testing REBOL Function Summary"
having read how easy and convenient it is to do this, I excitedly tried to send myself a test email via my GMail account.
I looked at the official GMail help for SMTP/POP to get the relevant SMTP/POP server names:
https://support.google.com/mail/answer/7104828?hl=en
And here is how far the "send" and "set-net" documentation got me:
>> set-net [ myrealusername#gmail.com smtp.gmail.com pop.gmail.com ]
>> send myrealusername#gmail.com "Hello me!"
connecting to: smtp.gmail.com
** Access Error: Cannot connect to smtp.gmail.com
** Where: open-proto
** Near: smtp-port: open [scheme: 'esmtp]
either only
On reflection, of course it didn't work; I told REBOL nothing about wanting to use SSL/TLS, the relevant port numbers, or my GMail password. It must need all of the above to actually send an email.
So how do I do it?
I modified the protocols some years ago to work with gmail. I hope that they still work.
You'll need to run both the prot-ssmtp.r and prot-ssend.r, and you'll need a version of rebol2 which supports ssl. This is either a free view build, or a paid core build.
do https://raw.githubusercontent.com/gchiu/Rebol2/master/Protocols/prot-ssmtp.r
do https://raw.githubusercontent.com/gchiu/Rebol2/master/Protocols/prot-ssend.r
Now, you can either set the user and password manually:
system/schemes/esmtp/user: "username"
system/schemes/esmtp/pass: "password"
or, when the script runs the very first time, you will be asked the values so that they can be set for that rebol instance. The prot-ssmtp uses port 465 but you can modify that if it's no longer correct.
And then it should be as straight forward after setting set-net as:
ssend email#someon.com "This is my message"
Note that we now have email on ren-c which is the open source fork of rebol3.

Bolt CMS - Email host connection timeout when using SimpleForms

I'm currently trying to set up a website using Bolt CMS. For a simple contact form, I'm trying to use the "SimpleForms" extension. For this, it seems I have to set up a "mailoptions" field in "config.yml".
Now, for the mail host I use Zoho Mail. I have successfully made an account, verified my domain and so on. My current mailoptions values in the config look like this:
mailoptions:
transport: smtp
host: smtp.zoho.com
port: 465
username: ****
password: ****
auth_mode: null
encyption: null
senderMail: null
senderName: null
Notice, I've obviously just inserted some stars where the username and password is supposed to go :-)
Now, I'm not exactly sure what values are allowed for the last 4 fields. I have not for the life of me been able to find any documentation on this. However, if I simply try to send an email through a SimpleForms contact form with these settings, I get the following error:
Swift_TransportException:
Connection to smtp.zoho.com:465 Timed Out
Again, haven't been able to find much info on this problem. My initial guess is that it might have to do with me not properly setting the last 4 fields, however I just do not know what they are supposed to be :( All I know, from following a DigitalOcean tutorial (I use DigitalOcean as server host), is that the settings are supposed to be as follow:
SMTP Host: smtp.zoho.com
SMTP Port: 465
Use SSL Encryption: Yes, use SSL encryption
SMTP Authentication: Yes, use SMTP authentication
Email Address or Username: The email address that you set up in the previous step. In our example, the email address is "application#example.com"
Email Name: The name associated with the email address. In our example, the name of the email is "Application Mail"
Email Password: The password that you set when you created the application mail account
I have tried different values for auth_mode and encryption, such as:
auth_mode: smtp
encryption: ssl
However, this still gives me the same timeout error.
[EDIT]
So, I was able to find the actual documentation for the values (which is Swiftmailer related). My current settings looks like this:
mailoptions:
transport: smtp
host: smtp.zoho.com
port: 465
username: ****
password: ****
auth_mode: login
encyption: ssl
senderMail: **** (The same as the username email)
senderName: **** (The name of the email account holder)
I've also double checked the mail settings from Zoho's own website, HERE.
This all seems to be correct settings, however I am still getting the original timeout message :(
EDIT
Check the comment of the answer for my stupid mistake :)
Bolt just uses Swiftmailer via the Silex service provider. The Silex documentation page probably has the answers you're looking for… namely:
The following options can be set:
host: SMTP hostname, defaults to 'localhost'.
port: SMTP port, defaults to 25. username: SMTP username, defaults to an empty string.
password: SMTP password, defaults to an empty string.
encryption: SMTP encryption, defaults to null. Valid values are 'tls', 'ssl', or null (indicating no encryption).
auth_mode: SMTP authentication mode, defaults to null. Valid values are 'plain', 'login', 'cram-md5', or null.
For anyone having this problem, do check with your host if there is a security setting that disallows outgoing SMTP.

Sending email using nodemailer doesn't works on internet service but on local server

I am trying to send email from my node.js app using nodemailer. I am successful in sending email from my local server after enabling less secure apps on google account.
But when I deployed my code to heroku, it is unable to send email because google is blocking my login attempts. So I logged in to my account and clicked on the option that the login attempt was from me indeed. However it still is not working. I then set up a project on runnable.com and got the same sign in prevented. I did the same for this and accepted it as my sign in attempt. However I am still not able to send emails.
The error that is coming is this :
Server listening on port 80
Failed in sending mail
{ success: false, existing: false, sendError: true }
{ [Error: Invalid login]
code: 'EAUTH',
response: '534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbsNg\n534-5.7.14 LiCfP8u0IX20V3Y1nFt7iYuwJCPg4LVgRxVvEPO5y4-XOjzSsm_xa0XIBE3NP2bM5euv4A\n534-5.7.14 m6LSg0_DQ
Qj9kOm_JuwykQxVyYSKaLGyeibhi_cHtx3Pu4I4UISJCPt3TvHdxCUebMzTbu\n534-5.7.14 2F9wLa-IFpKHf9HPap4Aeu11Nup9ZAlpOCGAmcnbERFeAufeIgAsExtGkrmV2X7mktJ5nq\n534-5.7.14 epNHDpwg2EwMVwzOrpt8rGZahYvs> Please log i
n via your web browser and\n534-5.7.14 then try again.\n534-5.7.14 Learn more at\n534 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 a76sm5828252oig.11 - gsmtp',
responseCode: 534 }
Please Help. I am in desperate need of getting it running.
I have the same issue, grap the link on your respone message "https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbsNg\n534-5.7.14" and paste to browser, you will see an announcement that showing google just blocked your sign-in request by cause it perform from strange device, then you can follow google instruction to accept that device.
It's work in my case. But I don't know what happen if heroku dynos sleep then waked up again, maybe it change the machine and you would got this problem again.
In this case, considering using a vps for hosting your mailing app.

Unable to send email from Ghost

I have been wrestling with this for days. I am exasperated in extremis.
I have a hosted Ghost blog at umquhile.org/kelpie. It has been working fine. Somehow I locked myself out of my account. 75,000 posts say I need to set up email so I can click on "Forgotten Password". I have gone by 12,000 posts (okay, a SLIGHT exaggeration) that show how to do it. First, Ghost's tutorial flat does not work. I have tried vanilla sendmail (which is expected not to work), Mailgun, Sendgrid, and Gmail. I have gone over my configuration repeatedly.
I get different error messages depending on how I set it up. Sometimes I have gotten a 535 - invalid login credentials, sometimes all recipients rejected; right now I am getting "Cannot read property 'count' of undefined", whatever that one is. Can someone tell me if there is a problem with this configuration. Or how-the-deuce to get email to work in Ghost.
I should note that I have restarted node.js each time I made a change.
config = {
// ### Production
// When running Ghost in the wild, use the production environment
// Configure your URL and mail settings here
production: {
url: 'http://umquhile.org/kelpie',
mail: {
service: 'Gmail',
fromaddress: ‘xxxx#gmail.com',
transport: 'SMTP',
options: {
host: 'smtp.gmail.com',
secureConnection: true,
port: 465,
auth: {
user: ‘xxxx#gmail.com',
pass: ‘xxxxxxxxxxxxxx’
}
}
},
For what is's worth, I read that Ghost uses Bcrypt hash for passwords. I have used an online Bcrypt generator to hash a password I provided. I copied the string and pasted it into the password field of my admin user in Mysql. That did not work because my account just flat remains locked.
And as soon as I post to stackoverflow, it hits me!!
I went into the database, via phpmyadmin, and found the field status
It was set to locked
I cleared the field, saved the change, and tadaaa! I am now able to access my blog once again. Sorry for the nuisance post! The answer JUST occurred to me.

smtp.gmail.com railo.runtime.exp.NativeException:javax.mail.AuthenticationFailedException:0

This works on my ColdFusion server, but not on my Railo server:
<cfset subject = "xxx">
<cfmail usessl="yes" username="xxx#gmail.com" password="xxx" port="465" type="html" server="smtp.gmail.com"
subject="#subject#"
from="xxx#gmail.com" to="xxx#gmail.com">
#subject#
</cfmail>
When I turn Spool enable off my Railo server, I get:
smtp.gmail.com
railo.runtime.exp.NativeException:javax.mail.AuthenticationFailedException:0
At first, Google balked at a program trying to login as me in a different city, but I've told them it was me.
Under unusual activity, I have:
You recognized all the unusual activity below as yours
And the Railo server is in the list.
http://email.about.com/od/gmailtips/qt/How-To-Unlock-Gmail-For-A-New-Email-Program-Or-Service.htm
says to go to
Allow a new application to access your account page at Google.
Also this page:
http://www.placona.co.uk/132/vps/full-google-mail-smtp-power-for-your-domain/
said to use port 587 and usetls instead of usessl.

Resources