Support » Plugin: SparkPost » Usage of email templates

  • I’m trying to find an alternative to Mandrill. I used your plugin however I’m not able to use the Template functionality.

    I’ve created a template & selected its ID in the WordPress plugin, but the email sent is not using the template. It is however being tracked in Sparkpost, but being sent without the template.

    Please help.

    https://wordpress.org/plugins/sparkpost/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor rajuru

    (@rajuru)

    Hi @amrinh
    Can you use the Test email feature that is available in plugins settings page. Don’t forget to check Show email debugging messages. Please create an issue on https://github.com/SparkPost/wordpress-sparkpost/pulls with the debug message (remove any private information while you do that).

    Thanks

    Is it possible to add customization in functions.php to change the email template based on the value of the autotags in wordpress?

    Here’s the code I used for Mandrill, appreciate help in transitioning to SparkPost.

    /* Set Mandrill Template */
    function changeMandrillTemplate($message) {
        // convenience variable
        $autoTags = $message['tags']['automatic'];
        // Is it an Ambassador Program email? //
        // Is it a Contact Form email? //
        if (strpos(implode(',', $autoTags),'wp_WPCF7_Mail') !== false) {
        	$message['template']['name'] = 'contact-template';
    	}
    		// Is it a Wordfence email? //
        elseif ( (strpos(implode(',', $autoTags),'wp_wordfence') !== false) or (strpos(implode(',', $autoTags),'wp_wf') !== false)
        		or (strpos(implode(',', $autoTags),'wp_WP_Automatic_Updater') !== false) ) {
        	$message['template']['name'] = 'admin-template';
    	}
    	// Is it a new user email? //
        elseif (strpos(implode(',', $autoTags),'wp_newuser_notify_siteadmin') !== false) {
        	$message['template']['name'] = 'admin-template';
    	}
        // General Template Specified in Plugin Settings //
        return $message;
    }
    // Don't forget to register the filter!
    add_filter('mandrill_payload', 'changeMandrillTemplate');
    
    /* Convert All Double Line Breaks to html Paragraph Tags */
    function op_mandrill_payload($message) {
        // Add wpautop to message content
        $message['template']['content'][0]['content'] = wpautop($message['template']['content'][0]['content']);
        return $message;
    }
    add_filter('mandrill_payload', 'op_mandrill_payload');

    I second this. Any luck with customization similar to the mandrill payload where we can select the templates programmatically depending on which email is being sent? (ex. New account would have a template, password reset can use another template, etc…)

    Thanks.

    I am having an issue with templates.

    Sparkpost requires email templates to have a subject and a “from” added when creating the template.

    When my site sends email, using this template, sparkpost is overriding the email subjects by the subject set up in the template.

    Any help is appreciated.

    Where are we supposed to use this? :

    Use {{subject}} and {{from_name}} in your template to allow substitution of Subject and From Name respectively.

    Inside your sparkpost template settings

    https://snag.gy/xiV5BQ

    Thanks for your reply @asharppencil,

    It does work with {{subject}} , but it doesn’t work with {{from_email}} @ xyz.com

    Also, when using templates – the replacement for “reply-to” doesn’t work, it’s like as if it was hardcoded to just use the ‘from’ header…

    That’s as far as I have got using templates..

    You can’t use {{from_email}} @ xyz.com. It should only be {{from_email}} as the whole thing gets subbed in.

    It appears you can only use one template (the one you selected in wordpress) and cannot change it depending on where the email originates like Mandrill using code (what rbarron said)

    I hope theres an update soon to allow that.

    Note that with the release of 2.3.0 you can now substitute the entire from address – please read this article to understand how to set up templates for proper substitution: https://support.sparkpost.com/customer/portal/articles/2409547-using-templates-with-the-sparkpost-wordpress-plugin

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Usage of email templates’ is closed to new replies.