When sending emails through PHP's native mail() function on a server configured with SPF, DomainKeys, and DKIM (such as Plesk), desktop mail clients (Outlook, Thunderbird) may sign outbound emails correctly, but emails dispatched from web scripts fail DKIM verification with invalid domain signatures.
From: string inside $additional_headers causes the sendmail wrapper to misidentify the originating signing domain d=$DOMAIN.
The Problematic Call
// This breaks DKIM signatures by overriding the sender envelope incorrectly:
mail($to, $subject, $message, "From: Name <user@domain.com>");
The Solution
Explicitly pass the envelope sender using the -f flag in the 5th parameter ($additional_parameters):
// Correct invocation with verified envelope sender:
mail($to, $subject, $message, "", "-f user@domain.com");
Verification Tip: Send a test email to check-auth@verifier.port25.com. The automated robot will reply within seconds with a detailed SPF, DKIM, DomainKeys, and SpamAssassin diagnostic report.
No comments:
Post a Comment