• Resolved daanburozero

    (@daanburozero)


    Hi There,

    Currently I’m using your plugin to send emails with SendGrid. There’s only one thing I can’t seem to figure out.

    SendGrid has a feature to add categories to specific emails. Therefore you need to use the “X-SMTPAPI” header. For some reason I can’t add this header to the wp-mail headers.

    Could you help me out?

    Thanks in advance

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter daanburozero

    (@daanburozero)

    Quick note, I’ve tried some stuff with filters like; ws_add_site_header and wp_mail_smtp_providers_mailer_get_body

    Plugin Author Gregor Capuder

    (@capuderg)

    Hi,

    as far as I understand the “X-SMTPAPI” is a Sendgrid SMTP sending feature, but our plugin is using their API v3 for sending emails.

    It looks like you will need to use the wp_mail_smtp_providers_mailer_get_body filter and add a “categories” array key, with your desired category name as the value. More info in the Sendgrid API docs, search for “categories” (in the content of the linked page and not the side menu on the left).

    Take care!

    Thread Starter daanburozero

    (@daanburozero)

    So this should be:

    function wp_mail_smtp_add_cat( $body, $mailer ) {
    	$body['categories'] = array('cat1', 'cat2');
    	return $body;
    }
    add_filter( 'wp_mail_smtp_providers_mailer_get_body', 'wp_mail_smtp_add_cat', 10, 2 );
    Plugin Author Gregor Capuder

    (@capuderg)

    Hi,

    yes, the code looks good to me.

    Take care!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Create categories for emails – Sendgrid’ is closed to new replies.