Title: html and text emails from same plugin
Last modified: September 21, 2017

---

# html and text emails from same plugin

 *  Resolved [arathra](https://wordpress.org/support/users/arathra/)
 * (@arathra)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/html-and-text-emails-from-same-plugin/)
 * I need to send both HTML and TEXT emails. If I set the plugin to text/plain then
   the text emails go fine but the HTML emails look weird.
 * Likewise, if I change the plugin to text/html then the HTML emails look fine 
   but the text ones look weird (even though I have ‘don’t convert to HTML’ set 
   in the SendGrid site settings).
 * Ideally I’d like to be able to set the content type in the headers as I did when
   I used the non-SendGrid wp_mail.
 * `$headers = array( 'Content-Type: text/html' );`
 * But… how can I do that in the SendGrid headers?
 * `$headers = new SendGrid\Email();`
    `$headers->setUniqueArgs(array( 'arg1' =>
   $pTitle ))` `->addCategory('my_category');`
 * Where can I add the content type to this?
 * Thanks.

Viewing 1 replies (of 1 total)

 *  Anonymous User 12640152
 * (@anonymized-12640152)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/html-and-text-emails-from-same-plugin/#post-9531852)
 * Hello.
 * You can customize each part of the email by using the `SendGrid\Email` class 
   from the sendgrid-php library. The plugin comes with version 4.0.2 of the official
   SendGrid PHP library.
 * You can use an instance of the `SendGrid\Email` class with `wp_mail()` to send
   custom emails. You can find an example in the plugin FAQ under “How can I further
   customize my emails?”, quote:
 *     ```
       $email = new SendGrid\Email();
       $email
           ->setFrom('me@bar.com')
           ->setHtml('<strong>Hello World!</strong>')
           ->addCategory('customCategory')
       ;
   
       wp_mail('foo@bar.com', 'Subject goes here', 'Message goes here', $email);
       ```
   
 * You can find examples and documentation for version 4.0.2 of sendgrid-php here:
   [https://github.com/sendgrid/sendgrid-php/tree/v4.0.2](https://github.com/sendgrid/sendgrid-php/tree/v4.0.2)
 * Also, you can add custom filters to change the content of emails on the fly for
   both content types. You can see an example in the plugin FAQ under “Can I change
   the content of the emails before they are sent ?”.
 * The FAQ is available on our plugin page here: [https://wordpress.org/plugins/sendgrid-email-delivery-simplified/](https://wordpress.org/plugins/sendgrid-email-delivery-simplified/)
 * Thank you,
    SendGrid

Viewing 1 replies (of 1 total)

The topic ‘html and text emails from same plugin’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/sendgrid-email-delivery-simplified_264460.
   svg)
 * [SendGrid](https://wordpress.org/plugins/sendgrid-email-delivery-simplified/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/sendgrid-email-delivery-simplified/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/sendgrid-email-delivery-simplified/)
 * [Active Topics](https://wordpress.org/support/plugin/sendgrid-email-delivery-simplified/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sendgrid-email-delivery-simplified/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sendgrid-email-delivery-simplified/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: Anonymous User 12640152
 * Last activity: [8 years, 8 months ago](https://wordpress.org/support/topic/html-and-text-emails-from-same-plugin/#post-9531852)
 * Status: resolved