• I am a newish coder trying to get mandrill running on my site. So far everything is working well but for the life of me i can’t figure out how to add the custom headers that mandrill picks up. I have a plugin i created that already uses the wp_mail function, I like how mandrill takes over if it is available but i don’t want to code specifically for it.

    Could someone help me understant how to add a custom tag for mandrill

    currently i set the headers for wp_mail like this

    $headers[] = 'From: ' . get_option('a3_from_address');
    	$headers[] = 'X-MC-Tags": test';
    	$headers[]...

    then i pass the $headers variable to wp_mail along with the rest:

    wp_mail($email_address, $subject, $body, $headers)

    I know this is wrong, but for the life of me i can’t figure out how to set the custom tag. I have repeatedly looked in the Mandrill help area, but nothing specifically about how to make this work in the context of the word press plugin and wp_mail.

    Thanks everyon

    https://ww.wp.xz.cn/plugins/wpmandrill/

Viewing 1 replies (of 1 total)
  • Hi kaysg,

    To apply the custom MailChimp header for your outbound email, you should add the following code to your plugin file OR theme’s functions.php file.

    /**
     * Add a custom header to all outbound WP emails for MailChimp.
     *
     * @param  array $params All email parameters.
     * @return array         Modified email parameters.
     */
    function appthemes_add_email_headers( $params ) {
        $params['headers'] = $params['headers'] . "X-MC-Tags: WordPress\n";
        return $params;
    }
    add_filter( 'wp_mail', 'appthemes_add_email_headers' );
Viewing 1 replies (of 1 total)

The topic ‘adding tags to headers’ is closed to new replies.