Support » Plugin: Product Enquiry for WooCommerce » Enhancement Request to Improve Email Deliverability

  • Resolved Tim Smith

    (@creativeinfusion)



    The enquiry emails as currently constituted flag the following issues with Spam Assassin HTML_MIME_NO_HTML_TAG, MIME_HTML_ONLY, TO_NO_BRKTS_HTML_ONLY

    When coupled with a customer email using, for exampe a yahoo address that also triggers FREEMAIL_FORGED_REPLYTO, which on some hosts (e.g. Heart Internet) means that the sending mail server does not send the enquiry, and on others means that incoming spam filters block the messages.

    Deliverability would improve with a few enhancements to the code.

    To fix TO_NO_BRKTS_HTML_ONLY I suggest changing:

    foreach ($recipient_email as $singleEmail) {
        array_push($recipient_emails, $singleEmail);
    }
    if (isset($form_data['send_mail_to_admin'])) {
        array_push($recipient_emails, $admin_email);
    }

    to:

    foreach ($recipient_email as $singleEmail) {
        $singleEmail = ucwords(str_replace('.',' ',substr($singleEmail, 0, strpos($singleEmail, '@'))))." <$singleEmail>";
        array_push($recipient_emails, $singleEmail);
    }
    if (isset($form_data['send_mail_to_admin'])) {
        array_push($recipient_emails, ucwords(str_replace('.',' ',substr($admin_email, 0, strpos($admin_email, '@'))))." <{$admin_email}>");
    }

    and the same change on Author Email address, and make both the reply to email address & customer copy email address become “$name <$to>”

    To fix HTML_MIME_NO_HTML_TAG, I suggest adding:
    <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body>
    to the start of the mail body, with appropriate closing tags on normal and admin mail body

    To fix MIME_HTML_ONLY, you could follow the advice on https://core.trac.wordpress.org/ticket/15448#comment:44 and remove all your own headers (except the reply to) and instead use phpmailer to set the alternative plain text and appropriate headers by adding this before any emails are sent in your plugin:
    add_action( 'phpmailer_init', $alt_function = function( $mailer ) { $mailer->AltBody = strip_tags( $mailer->Body ); } );
    and this after they have all been sent (to avoid interfering with any normal WordPress Admin emails):
    remove_action( 'phpmailer_init', $alt_function );

Viewing 1 replies (of 1 total)
  • Plugin Author WisdmLabs

    (@wisdmlabs)

    Hi Tim,

    Thanks for your suggestions and we will definitely consider these in our future plugin updates.

Viewing 1 replies (of 1 total)
  • The topic ‘Enhancement Request to Improve Email Deliverability’ is closed to new replies.