{"id":19007492,"date":"2026-08-31T12:50:15","date_gmt":"2026-08-31T12:50:15","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/reply-to-snippet-provided-from-you\/"},"modified":"2026-08-31T12:50:15","modified_gmt":"2026-08-31T12:50:15","slug":"reply-to-snippet-provided-from-you","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/reply-to-snippet-provided-from-you\/","title":{"rendered":"reply-to snippet provided from you"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hi SureMail team,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I\u2019m following up regarding the Reply-To snippet you previously provided:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter( 'wp_mail', function( $atts ) {\n    \/\/ Add reply-to header if not already present\n    if ( ! empty( $atts&#091;'headers'] ) ) {\n        $headers = is_array( $atts&#091;'headers'] ) ? $atts&#091;'headers'] : explode( \"\\n\", $atts&#091;'headers'] );\n\n        \/\/ Check if reply-to already exists\n        $has_reply_to = false;\n        foreach ( $headers as $header ) {\n            if ( stripos( $header, 'reply-to' ) !== false ) {\n                $has_reply_to = true;\n                break;\n            }\n        }\n\n        if ( ! $has_reply_to ) {\n            $headers&#091;] = 'Reply-To: Your Name &lt;replies@example.com&gt;';\n            $atts&#091;'headers'] = $headers;\n        }\n    }\n\n    return $atts;\n} );\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We are currently troubleshooting an Apple DKIM body hash verification failure, and MailChannels (Hostinger\u2019s relay) reviewed the situation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">They said that the snippet is not necessarily directly causing the DKIM body hash failure, since Reply-To is a header and the error concerns the DKIM body hash (<code>bh=<\/code>). However, they pointed out that the way the snippet handles the headers could potentially introduce line-ending inconsistencies.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Specifically, they highlighted this line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>explode( \"\\n\", $atts&#091;'headers'] )\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Their concern is that if <code>$atts['headers']<\/code> contains CRLF (<code>\\r\\n<\/code>) line endings, splitting only on <code>\\n<\/code> can leave trailing <code>\\r<\/code> characters in individual headers. Depending on how WordPress\/PHPMailer subsequently rebuilds the message, this could potentially result in inconsistent LF\/CRLF handling.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">MailChannels also suggested forcing SMTP-standard CRLF line endings and quoted-printable encoding through <code>phpmailer_init<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_action( 'phpmailer_init', function( $phpmailer ) {\n    $phpmailer-&gt;LE = \"\\r\\n\";\n    $phpmailer-&gt;Encoding = 'quoted-printable';\n} );\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Could you please review the Reply-To snippet you provided and confirm whether its handling of <code>$atts['headers']<\/code> is safe?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In particular:<\/p>\n\n\n\n<ul>\n<li>Could <code>explode( \"\\n\", $atts['headers'] )<\/code> leave stray <code>\\r<\/code> characters or otherwise affect PHPMailer message formatting?<\/li>\n\n\n\n<li>Would you recommend normalizing the headers before converting them to an array?<\/li>\n\n\n\n<li>Is there a safer SureMail-compatible way to add Reply-To without modifying the raw <code>wp_mail<\/code> headers in this manner?<\/li>\n\n\n\n<li>Do you see any conflict with setting <code>$phpmailer-&gt;LE = \"\\r\\n\"<\/code> and <code>$phpmailer-&gt;Encoding = 'quoted-printable'<\/code> via <code>phpmailer_init<\/code>?<\/li>\n\n\n\n<li>Ideally, could you provide a corrected version of the Reply-To snippet that preserves proper CRLF handling?<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">We\u2019re trying to eliminate anything at the WordPress\/SureMail level that could alter the message after the DKIM body is generated or cause inconsistent message canonicalization.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks!<\/p>\n","protected":false},"template":"","class_list":["post-19007492","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19007492","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19007492\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=19007492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}