Connection could not be established with host imap.gmail.com (Sending from Invoice Ninja)

chrisdewey

Verified User
Joined
May 27, 2020
Messages
7
Hello,

I am been battling to find a cause and solution for me not being able to get emails working in Invoice Ninja, No matter what email system I use it says the same thing. I have used RoundCube from the same DirectAdmin Server, 2x Gmail Accounts (1 New and the other worked over a year ago on v4 Invoice Ninja) and I have tried Hotmail. All Say the following.

System Failed to email Invoice 0001
Connection could not be established with host imap.gmail.com :stream_socket_client(): unable to connect to SSL://imap.gmail.com:465 (Connection Refused)
I have tried smtp.gmail.com and all the 25,465,587

I have carried out the following:
Checked TCP_Ports and SMTP_PORTS

I have followed what Invoice Ninja recommends
Changed
QUEUE_CONNECTION=database to QUEUE_CONNECTION=sync
Checked Cron Is working (I know this should not affect)
PHP artisan queue:listen


.env - details
MAIL_MAILER=smtp
MAIL_HOST=imap.gmail.com
MAIL_PORT=465
MAIL_USERNAME=[email protected]
MAIL_PASSWORD=PASSWORD
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=[email protected]
MAIL_FROM_NAME='CD Emails'

Any help in getting Invoice Ninja to send emails that would be great. I am posting here as I suspect DirectAdmin or Underlining OS causing it as its a clean install and a clean install of Invoice Ninja
 
Last edited:
Ok so I tested emails using RoundCude and they work.

Reconfigured the .env file to the following.
MAIL_MAILER=smtp
MAIL_HOST=mail.domain.uk
MAIL_PORT=587
MAIL_USERNAME=[email protected]
MAIL_PASSWORD=PASSWORD
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=
MAIL_USERNAME=[email protected]
MAIL_FROM_NAME='CD Email'

Now get the following error. So it changes a little whilst I have been troubleshooting or I may have broken it even more lol.
System Failed to email invoice 0001
Connection could not be established with host mail.cd-medserve.uk @stream_socket_clients(): SSL operation failed with code 1. OpenSSL Error Messages: Error:1408F10B:SSL routines:ssl3_get_record:wrong version number
 
Last edited:
Changed the SSL to TLS and its now working.

does not explain why external Email Providers don't work. But happy to keep the say it is now.
 
try check option in CSF Firewall Config, "SMTP_BLOCK" should set to 0
 
Back
Top