7

I use the Sendgrid PHP API and would like to send emails in both text/plain and text/html,

I tried :

$request_body = json_decode('{
    "content": [
       {
          "type": "text/plain", 
          "value": "text version"
       },
       {
          "type": "text/html", 
          "value": "html version"
       }
     ], 
     "subject": "blabla €",
     ...
  }');

  $response = $sg->client->mail()->send()->post($request_body);

Result :

  • no error are generated by Sendgrid.

  • the subject becomes "blabla €" (if only text/html, the subject received is fine "blabla €")

  • and I receive an email with only this content-type :

Content-Type: text/html; charset=UTF-8

Result expected :

I would like to send an email simply with 2 content types :

Content-Type: text/plain; charset=UTF-8

and

Content-Type: text/html; charset=UTF-8

is it possible ? Any idea ?

3
  • 3
    Any update on this?
    – Miguel
    Commented Mar 30, 2017 at 14:35
  • I have yet to get this to work either Commented Aug 4, 2017 at 21:07
  • does encoding the subject yourself works? check this. It used to happen in the Java library as well but they fixed it
    – Boaz
    Commented Sep 2, 2018 at 8:41

0

Browse other questions tagged or ask your own question.