SMTP ERROR: Failed to connect to server: (0)

SMTP ERROR: Failed to connect to server: (0)

by Hamza Amri -
Number of replies: 3

Hello 

I'm having issues with automatic sending mails ( for example in case add new user, generate password and notify user ). 

The debug smtp erros after adding new user, is as follow : 

	Connection: opening to ssl://mail.website.com:465, t=10, opt=array (
                   	                  )
	SMTP ERROR: Failed to connect to server:  (0)
	SMTP connect() failed.
I am running Moodle 2.9.9 on a linux server 


Version  cPanel64.0 (build 11)
Version Apache2.2.31
Version  PHP5.5.30
Version MySQL5.6.35
Architecturex86_64
Oslinux

i'm using the following Cron job : 

*/5****/usr/bin/php -q public_html/admin/cli/cron.php?password=password >/dev/null 2>&1
 

and the following SMTP configuration (plugin>message output> email) :

SMTP hosts: mail.website.com:465

SMTP security: SSL

SMTP username: username

SMTP password: password

Newline characters in mail: CRLF

(i tried also a non securised connexion configuration with the default port 25, always the same error)

Anyone have any suggestions where I should start looking to figure out what's going wrong?

Thanks!

Average of ratings: -
In reply to Hamza Amri

Re: SMTP ERROR: Failed to connect to server: (0)

by Colin Fraser -
Picture of Documentation writers Picture of Testers

Talk to your ISP first, perhaps the port is wrong, the path is wrong... anything could be wrong. The port number is 465? Should it be set to another number? Like the default 25? Perhaps Elastic Email? The port there is 2526 from memory... I understand Amazon does something different again, so if you are using Amazon then .... 

I also seem to recall that 465 was not issued, if that is the right word, as an "official" port number for SMTP, although I can't think of seeing any "official" set of port numbers anyway... 


In reply to Colin Fraser

Re: SMTP ERROR: Failed to connect to server: (0)

by Hamza Amri -

Hi 

The port and the path aren't wrong ! i forgot to precise, Sending emails was working normally till we installed another local plugin and changed some configurations ! I uninstalled the plugin and reconfigured moodle again. Still haven't solved this issue.  any suggestions?

Thank you 

 

In reply to Hamza Amri

Re: SMTP ERROR: Failed to connect to server: (0)

by Ken Task -
Picture of Particularly helpful Moodlers

Networking comes before application (Moodle and Mail).   Since you've said you had a plugin that has been removed successfully and re-configured the smtp service back to what what it was ... are you sure that the Moodle can see the mail server itself ... at port shown.

Since it's linux, ssh into server and as root user of the system, install nmap ... a command line network scanner.

Once nmap is installed test the networking ... via this command:

nmap -P0 -p 465 [IPaddressorFQDNofMailServer]

IF nmap returns that port is closed ... not open ... then the issue very well could be on the mail server end.

'spirit of sharing', Ken