So I am using phpmailer using smpt and it is going thru postfix to send emails. When I send a email from my email it goes thru without a problem when it comes to using DKIM and DMARC. But when I send using phpmailer Im not getting a DKIM.
<?php
function send_email($to, $from_email, $from_name, $subject, $body,
$is_html=false, $attachments=null) {
global $smtp_host, $smtp_port, $smtp_user, $smtp_password;
try {
$email = new PHPMailer(true);
if ($from_email === $smtp_user) {
$email->isSMTP();
$email->Host = $smtp_host;
$email->Port = $smtp_port;
$email->SMTPAuth = true;
$email->Username = $smtp_user;
$email->Password = $smtp_password;
$email->SMTPSecure = 'tls';
}
$email->CharSet = 'UTF-8';
$email->From = $from_email;
$email->FromName = $from_email;
$email->Subject = $subject;
$email->Body = $body;
$email->AddAddress($to);
if ($is_html == true) {
$email->IsHTML(true);
$email->Encoding = 'base64';
}
if ($attachments != null) {
foreach ($attachments as $attachment) {
$apath = $attachment["path"];
$aname = $attachment["name"];
$email->AddAttachment($apath , $aname);
}
}
$email->Send();
$status = "success";
}
catch (phpmailerException $e) {
$status = $e->errorMessage();
}
catch (Exception $e) {
$status = $e->getMessage();
}
return $status;
}
So I think I need to add this to my code but I'm not sure if I have to add this to the code. I was thinking that opendkim would just add the DKIM to the header. But its not.
$email->DKIM_domain = 'mydomain.com';
$email->DKIM_private = '/path/to/private_key';
$email->DKIM_selector = 'default';
$email->DKIM_passphrase = '1234567';