Jump to content

WHMCS v7 - SMTP connect() failed


Recommended Posts

Hello,

 

i am trying to use Secure SMTP for sending emails in WHMCS. I set SMTP port to 465 and check the SSL checkbox.

I already use SSL for sending emails in Outlook and Thunderbird for several years without problems using 465 port and SSL.

 

When i try to send an email from WHMCS with the above settings i get an error:

An Error Occurred

SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

 

If i enable SMTP_debug in configuration.php i get this error:

 

2017-03-16 06:38:33 Connection: opening to ssl://mailserver.domain.com:465, timeout=300, options=array ( ) 2017-03-16 06:38:33 Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client(): Peer certificate CN=`hostname.domain.com' did not match expected CN=`mailserver.domain.com' 2017-03-16 06:38:33 Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client(): Failed to enable crypto 2017-03-16 06:38:33 Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client(): unable to connect to ssl://mailserver.domain.com:465 (Unknown error) 2017-03-16 06:38:33 SMTP ERROR: Failed to connect to server: (0) 2017-03-16 06:38:33 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

 

Email Sending Failed - SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

 

i tried editing the vendor/phpmailer/phpmailer/class.phpmailer.php and set the public $SMTPAutoTLS = false; but still no success.

 

i can see it is complaining that mailserver doesn't match the hostname.

the mailserver is not the same with the server's hostname (should it be?)

the mailserver is on separate IP address (different class) than the hostname IP.

 

is htere any setting i can make in order to have the SSL SMTP working in WHMCS 7?

 

 

Thanks.

 

 

LE: forgot to mention: the error started after i upgraded PHP version to 5.6

Edited by minadreapta
Link to comment
Share on other sites

Hey Minadrepta,

 

Thanks for your post.

 

PHP 5.6 introduced new SSL requirements where it forces an SSL connection for SMTP. The issue here is that you don't have a valid SSL certificate for the SMTP Mail server entered into WHMCS.

A temporary work around for you to use while you get the SSL certificate to report back valid is to do the following:

 

 

Open the file WHMCSROOT/vendor/phpmailer/phpmailer/class.smtp.php and Find around line 247 the function

 

public function connect($host, $port = null, $timeout = 30, $options = array())
{
 static $streamok;

 

 

Add the following code so the function reads

 

public function connect($host, $port = null, $timeout = 30, $options = array())
{
 if( count( $options ) == 0 ) {
   $options["ssl"] = array( "verify_peer" => false, "verify_peer_name" => false, "allow_self_signed" => true );
 }

 static $streamok;

 

Save the file

 

NOTE: This is only a temporary work around as any full release upgrades of WHMCS will overwrite the change.

Details of this workaround can be found at https://github.com/PHPMailer/PHPMailer/issues/368

Another workaround which can be applied are published at https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#php-56-certificate-verification-failure

Link to comment
Share on other sites

after googling for a whilie i found a dirty workaround. i added some options to the class.phpmailer.php: 'verify_peer' => true, 'verify_peer_name' => false and 'allow_self_signed' => false

public $SMTPOptions = array(
'ssl' => array(
       'verify_peer' => true,
       'verify_peer_name' => false,
       'allow_self_signed' => false
   )
);

now the emails get send using the SSL option mentioned above.

 

any other thoughts on this?

 

thanks.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated