We use a PHPMailer
script on a server with Centos 7.0 and Postfix to send emails. Our server has an Open DKIM key and has an SPF record.
When we send messages one by one they arrive without problems, but when using the script they always go to SPAM, unless each user adds each account as a secure sender.
<?php
include_once('fk_clases/class.phpmailer.php');//PHPMailer
$Subject = "Mensaje sobre llave DKIM y PHP";
$BodyCorreo = "Esta es una prueba para verificar la entrega de un correo con llave OpenDKIM";
$mail = new PHPMailer(true);
$mail->IsSMTP();
$mail->Helo = "midominio.com";
$mail->SMTPAuth = true;
$mail->Port = 587; //puerto seguro
$mail->SMTPSecure = 'tls'; //Conexion cifrada TLS
$mail->Host = "mail.midominio.com";
$mail->Username = '[email protected]';
$mail->Password = 'mipassword';
$mail->AddReplyTo('[email protected]','Dennis');
$mail->From = '[email protected]';
$mail->FromName = 'Dennis';
$mail->AddAddress('[email protected]');
$mail->Subject = $Subject;
$mail->DKIM_domain = 'midominio.com';
$mail->DKIM_private = 'ruta de la llave';
$mail->DKIM_selector = 'default';
$file_to_attach = '/root/cola.log';
$mail->AddAttachment('/root/cola.log', 'cola.log' );
$mail->Send();