PHPMailer

Ive installed suiteCRM and sugarCRM previously and am having trouble getting a test email sent with both.
I keep getting the error “Error:SMTP connect() failed”.

I’m using Apache24 on a FreeNAS server and i want to use gmail for the outgoing server.
The outgoing mail server in suiteCRM is configured correctly.

To test my servers ability to send mail i have created a simple script PHP page which sends emails successfully.
This means my server is configured correctly and my php.ini must also be setup correctly.

For a reference the PHP code that works is…

<?php require("/usr/local/share/phpmailer/class.phpmailer.php"); require("/usr/local/share/phpmailer/class.smtp.php"); $mail = new PHPMailer(true); // create a new object $mail->IsSMTP(); // enable SMTP $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only $mail->SMTPAuth = true; // authentication enabled $mail->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for GMail $mail->Host = 'smtp.gmail.com'; $mail->Port = 587; $mail->SMTPAutoTLS = false; $mail->SMTPOptions = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ) ); $mail->Username = 'mattdmsa@gmail.com'; $mail->Password = 'stephaniesusan'; $mail->SetFrom('mattdmsa@gmail.com'); $mail->Subject = 'test'; $mail->Body = 'hello'; $mail->AddAddress('matthew@motion-solutions.com.au'); if(!$mail->Send()) { $error = 'Mail error: '.$mail->ErrorInfo; return false; } else { $error = 'Message sent!'; return true; } ?>

Now without …

$mail->SMTPOptions = array(
‘ssl’ => array(
‘verify_peer’ => false,
‘verify_peer_name’ => false,
‘allow_self_signed’ => true
)
);

…the mail is not successful.

So ive tried modifying the relevant php files in suiteCRM with no success.

After a week on this im ready to re-imburse someone to sort it.

Any takers or of course better still for me some advice ?

Thank you motionman, your script worked with my own details :

  • SuiteCRM 7.7
  • Ubuntu Server 16.04
  • NGINX 1.10.0
  • MySQL 14.14
    My mailserver is an Exchange with self signed cert.

On a 7.4 version of SuiteCRM running on an Apache with CENTOS I was able to send e-mail. But since I upgraded my system from 7.5 it’s impossible to send e-mails from SuiteCRM.
It’s a big issue and I’m loosing time on it :frowning:

Is someone able to find a solution?

Here was my solution.
But please remember i used this because i am using GMail as my outbound email server. I think its considered bad practice if you have an internal mail server where this would be a “band aid” to a larger problem on your server. I’m sure proper signed certs are the norm but we are using gmail as the outbound server.

Ok so problem solved.

Added …

$options = array(‘verify_peer’ => false, ‘verify_peer_name’ => false, ‘allow_self_signed’ => true);

To the beginning of function “connect” in “class.smtp.php”.

Ok so just realized im a dumbass for posting my PHP login script :unsure:
So not in IT but learning… fast

Ok so it’s broken again damn it. I keep getting “the following from address failed” when testing outbound email.
Any ideas on where to look would be wonderful…