I have problems sending emails from my production server with Symfony 2 , SwiftMailer and Gmail. When I send it from my localhost server no problem but when I test in the production server (Godaddy hosting) I get this error:
Connection could not be established with host smtp.gmail.com [Connection refused #111]
500 Internal Server Error - Swift_TransportException
I googled and tried many solutions without success. In localhost server it works with any simple configuration. This is my config.yml
Swiftmailer Configuration
swiftmailer:
transport: gmail
encryption: ssl
auth_mode: login
host: smtp.gmail.com
port: 587
username: myuser
password: mypassword
I put all the options for test but with email transport, username and password it works in localhost. I appreciated it any help in advance.
GoDaddy blocks all outgoing SMTP connections on their hosting. You will have to use their SMTP relay servers instead, or get a better host.
http://help.godaddy.com/article/955
http://www.satollo.net/godaddy-using-smtp-external-server-on-shared-hosting
Related
Email Sending failed from cpnel but it works fine in my localhost.
Here is my email configuration in .env file.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=myemail#gmail.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=ssl
It works fine in localhost but not working in cpanel. In cpanel it shows
Connection could not be established with host smtp.gmail.com [Connection refused #111]
How do i solve this?
Problem Solved.
I made the change two things here MAIL_DRIVER and MAIL_PORT.
MAIL_DRIVER=sendmail
MAIL_PORT=587
So, my full code is:
MAIL_DRIVER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail#gmail.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=ssl
It works fine
I know this question has been answered but I have an alternative solution that matches the original description and might help someone. You did not answer Loek's question about whether you run cPanel or not. We run cPanel with lfd/csf firewall, and it has TCP_OUT configuration that lists what outbound ports may be connected to. Port 465 (tls) was not in that list, so we got 'Connection Refused' reports, even trying a low level telnet test on the command line of our VPS server:
$ telnet smtp.gmail.com 465
Trying 74.125.140.109...
telnet: connect to address 74.125.140.109: Connection refused
Trying 74.125.140.108...
telnet: connect to address 74.125.140.108: Connection refused
Trying 2a00:1450:400c:c08::6d...
telnet: connect to address 2a00:1450:400c:c08::6d: Connection refused
The same telnet test worked fine from my local machine.
After adding 465 to the TCP_OUT list:
Load WHM control panel
go to ConfigServer Security & Firewall
go to Firewall Configuration
find TCP_OUT and include 465 (or whatever port you are trying to connect to) to the list
click Change at the bottom of the page, then Restart lfd/csf.
Telnet now succeeds, as does smtpauth mail sending via PHPMailer:
$ telnet smtp.gmail.com 465
Trying 74.125.140.109...
Connected to smtp.gmail.com.
Escape character is '^]'.
(this indicates the socket connection was established.. you probably don't want to actually talk SMTP to Google so hit ctrl-] and type quit and hit enter to close the connection)
Of course this isn't cPanel specific, you may be running another firewall manager that is not allowing outbound connections on the port you're trying to connect to.
After couple of days research. I was having issue of Connection could not be established with host smtp.gmail.com [Connection refused ] because of my godaddy server
As GoDaddy blocks SMTP communication over ports 465 and 587 and possibly 25 originating from your site. They will allow mail flow only through their own SMTP servers.
That was issue in my case. hope it helps someone
For reference check this:
https://pk.godaddy.com/community/Using-WordPress/Connection-Refused-for-GMail-SMTP/td-p/33107
I did face this issue before, I did allow less secure apps from google account manager. And my problem was solved.
It seems like that you too need authorization for extension application in order to use gmail.
You can follow given below steps...
Sign-in into your gmail account.
Access this link to change settings.
Then you have to turn on Allow less secure apps.
After that try again to send email through you host.
I made the nexts steps:
Enter to cPanel of GoDaddy
Go to the option > Email Accounts
Clic in the option > + Create and create a email.
and after change
I resolve this problem by changing the file .env
MAIL_MAILER=smtp
MAIL_HOST=localhost
MAIL_PORT=25
MAIL_USERNAME=null
MAIL_PASSWORD=
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=emailcreated#email.com
MAIL_FROM_NAME="NAME_APP"
I hope that help !!
I try to get the Gmail inbox emails using Eden mail PHP from my localhost (XAMPP Apache server). But it throws a fatal error:
Fatal error: Uncaught Eden\Mail\Exception: Problem connecting to
ssl://imap.gmail.com:993. Check server, port or ssl settings for your
email server.
in C:\xampp\htdocs\edenMail\vendor\eden\mail\src\Imap.php:357
Stack trace:
0 C:\xampp\htdocs\edenMail\vendor\eden\mail\src\Imap.php(170): Eden\Core\Exception::i()
1 C:\xampp\htdocs\edenMail\vendor\eden\mail\src\Imap.php(357): Eden\Mail\Imap->connect()
2 C:\xampp\htdocs\edenMail\index.php(36): Eden\Mail\Imap->getMailboxes()
3 {main}
thrown in C:\xampp\htdocs\edenMail\vendor\eden\mail\src\Imap.php on line 357
I have used below code in Eden mail's index.php file with my own credentials.
$imap = eden('mail')->imap(
'imap.gmail.com',
'myEmailId',
'myPassword',
993,
true);
In addition to that, I have enabled IMAP/POP3 and turned on less secure apps as well in my Gmail settings.
I have encountered this error only when I try to connect from my localhost (Windows-Xampp-Apache server). But there is no error if test code in my web server working in Linux environment.
Could anyone please help me to connect the google imap.gmail.com to retrieve inbox emails?
I have followed the instructions given in the below link and got the issue resolved. I am sharing it as if may help anyone with the same issue.
https://www.hesk.com/knowledgebase/?article=72
Having problems getting Gmail to work with HESK? Try these settings.
» Email sending
To send emails using Gmail server enter these details:
SMTP Host: smtp.gmail.com
SMTP Port: 587
SSL Protocol: OFF
TLS Protocol: ON
SMTP Username: (your Gmail username)
SMTP Password: (your Gmail password)
Also make sure your "From email address" in HESK settings is set to your Gmail email address!
Still no luck? Check with your host if they have port 587 blocked in firewall.
» POP3 fetching
To fetch mail from Gmail server enter these details:
POP3 Host: pop.gmail.com
POP3 Port: 995
TLS Protocol: ON
POP3 Username: (your Gmail username)
POP3 Password: (your Gmail password)
Important: make 100% sure that "POP3 download" in your Gmail settings
is set to "Enable POP for mail that arrives from now on". If not,
Gmail will send all existing (even read) messages to HESK when it
first connects.
» IMAP fetching
To fetch mail using IMAP from Gmail server enter these details:
POP3 Host: imap.gmail.com
POP3 Port: 993
Encryption: SSL
POP3 Username: (your Gmail username)
POP3 Password: (your Gmail password)
» Error messages
Connection timed out
Required ports are probably blocked on your server's firewall. Ask your host to configure the firewall to allow TCP connections on ports 587, 995 and/or 993.
Some hosting companies will not do that due to their policies. In that case you will need to, in order to integrate Gmail with HESK, find another host or try the HESK cloud.
Permission denied
Try logging with your google account here to unlock it for application access.
Click the "Continue" button to Allow access to your Google account.
Password error: [AUTH] Username and password not accepted. Too many
login failures
Your username and/or password is not correct, double-check them ad remember passwords are CaSe SeNSiTiVe!
Password error: [AUTH] Web login required
See this article
Error: 0 could not connect to the host "pop.gmail.com"
This could mean that:
required ports are blocked on your server's firewall. Ask your host to unblock TCP connections on ports 587, 995 and/or 993
- OR -
SSL certificate verification fails on your server. Try this:
download this file
save it somewhere to your server, for example to C:\wamp\ssl\cacert.pem
open your php.ini file
find the line
;openssl.cafile=
and change it to the location of the cacert.pem file while also removing the starting ;
openssl.cafile=C:\wamp\ssl\cacert.pem
save and restart the server
test again
Trying to send email with Swiftmailer, I got this error. I've configured swiftmailer with:
transport: smtp
host: smtp.gmail.com
username: example#example.com
password: password
port: 587
encryption: ssl
I always get this error message:
Connection could not be established with host smtp.gmail.com
I've also tried with:
transport: gmail
host: smtp.gmail.com
username: example#example.com
password: password
port: 587
encryption: ssl
The complete error message is
[YYYY-mm-dd hh:ii:ss] app.ERROR: Exception occurred while flushing email queue: Connection could not be established with host smtp.gmail.com [ #0]
Other questions:
My case is different from this. In my case I've not Avast antivirus.
EDIT: changing port to 465, as Alex Howansky suggested, erro changes in
Exception occurred while flushing email queue: Failed to authenticate on SMTP server with username "my email address" using 1 possible authenticators
1: Either you must allow less secure apps or use app password by enabling 2 step verification on your gmail acc.
2: Disable any antivirus on your machine(this is something no one will tell u but is necessary in many cases).
3: Don't forget to clear your cache (sometimes it don't take updated content from .env file)
4: You don't need to change anything in Mailer inside config directory(not recommended), you should use env variables
it's looking for the server smtp.gmail.com but isn't able to resolve it. use this domain smtp.gmail.com and port 25 or 465.
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.
I have troubleshooting with sending emails at 1and1 hosting.
I use swift mailer lib message I receive is stream_socket_client(): unable to connect to mrvnet.kundenserver.de:0 http://mrvnet.kundenserver.de:0 (Connection timed out).
Does anyone have similar troubles? Any solution?
PS. At my localhost everything is OK.
I fix SMTP after contact with their support team.
SMTP parameters:
HOST: mrvnet.kundenserver.de
PORT: 25
AUTH: without auth
Contacted support, they asked me do not use encryption (neither ssl nor tls, both not acceptable), so my options are:
host: smtp.1and1.com
port: 25
login: somemail#somedomain.com
passwd: somestrongpassword=)
as you may mention i use 1and1's mail (same settings for gmail would not work)