I configured my mail server as in the following guide: https://www.digitalocean.com/community/tutorials/how-to-configure-a-mail-server-using-postfix-dovecot-mysql-and-spamassasin Now I am trying to send mails via PHP using this library: https://github.com/PHPMailer/PHPMailer
But the problem seems the SSL (cert). I am not sure if the script is not able to establish a connection or if the problem is the unverified SSL cert. Do you guys have any idea? Should I use startssl oder starttsl in the script?
SSLaccept error from x.com[x.x.x.x]: 0
Dec 8 17:45:23 x postfix/submission/smtpd[13479]: warning: TLS library problem: 13479:error:14094418:SSL routines:SSL3READBYTES:tlsv1 alert unknown ca:s3pkt.c:1258:SSL alert number 48:
My code so far:
function send_mail($from, $from_name, $to, $to_name, $subject, $content) { require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.x.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'noreply@x.com'; // SMTP username
$mail->Password = 'so secret'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->From = $from;
$mail->FromName = $from_name;
$mail->addAddress($to, $to_name); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $subject;
$mail->Body = $content;
$mail->AltBody = 'Please use an html compatible Client to view this mail!';
if(!$mail->send()) {
return false;
} else {
return true;
}
}