# PHP Email Service Payload Formatting

**URL:** <https://community.dreamfactory.com/t/php-email-service-payload-formatting/4390>\
**Category:** Server-Side Scripting\
**Created:** [April 21, 2018, 1:20am UTC](https://community.dreamfactory.com/t/php-email-service-payload-formatting/4390 "2018-04-21T01:20:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Harvey](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/mike_harvey/32/572_2.png) [@Mike\_Harvey](https://community.dreamfactory.com/u/Mike_Harvey)\
**Post date:** [April 21, 2018, 1:20am UTC](https://community.dreamfactory.com/t/php-email-service-payload-formatting/4390/1 "2018-04-21T01:20:37Z")

</div>

I have a PHP server side script and I need to send an email but cannot find an example on how to format the payload. This is what I have but am getting a rest exception saying the email address is invalid. How should i format the payload for my email service?

```
        $email_content = [
      'template' => 'retired__form',
      'to'=> [
          'name' => $org_admin_name,
          'email' => $org_admin_email
      ],
      'subject' => 'Retired Form Failure',
      'body_text' => 'Hi {name}, This is a notification for a retired form submission.',
      'from_name' => 'XXX Notifications',
      'from_email' => 'notifications@abc.com',
      'reply_to_name' => 'XXX Support',
      'reply_to_email' => 'support@abc.com',
      'org_admin_name' => $org_admin_name,
      'auditor' => $this_auditor,
      'form_name' => $form_name_pretty,
      'submission_date' => $nicedate,
      'institution' => $this_institution
    ];
```

---

<div class="post-metadata">

**Author:** ![Mike\_Harvey](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/mike_harvey/32/572_2.png) [@Mike\_Harvey](https://community.dreamfactory.com/u/Mike_Harvey)\
**Post date:** [April 21, 2018, 2:35pm UTC](https://community.dreamfactory.com/t/php-email-service-payload-formatting/4390/2 "2018-04-21T14:35:02Z")

</div>

And as a followup if I json\_encode this and test it with the API docs, the email goes through fine. For whatever reason using the post api doesn’t like this payload and reports an Invalid Email address. Any ideas would be helpful.

---

<div class="post-metadata">

**Author:** ![Mike\_Harvey](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/mike_harvey/32/572_2.png) [@Mike\_Harvey](https://community.dreamfactory.com/u/Mike_Harvey)\
**Post date:** [April 22, 2018, 5:23pm UTC](https://community.dreamfactory.com/t/php-email-service-payload-formatting/4390/3 "2018-04-22T17:23:42Z")

</div>

I resolved this. The array needs to sent as is and not as a resource to the service. FYI.

---

<div class="post-metadata">

**Author:** ![Erik\_Jacobsen](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/erik_jacobsen/32/1132_2.png) [@Erik\_Jacobsen](https://community.dreamfactory.com/u/Erik_Jacobsen)\
**Post date:** [April 24, 2018, 3:20pm UTC](https://community.dreamfactory.com/t/php-email-service-payload-formatting/4390/4 "2018-04-24T15:20:32Z")

</div>

Thanks for updating your thread with your solution @Mike_Harvey!
