1. Home
  2. Docs
  3. REST API Code Samples
  4. PHP

PHP

PHP# POST code sample

<?php
$url = "https://api.inwise.com/rest/v1/transactional/emails/sendTemplate";

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$headers = array(
"Content-Type: application/json",
"Accept: application/json",
"X-API-Key: XXXXXXXXXXX",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

$data = <<<DATA
{
"template_id": 123456,
"template_content": {
"contents": [
{
"name": "name",
"content": "html"
}
]
},
"message": {
"html": " ",
"text": "text text",
"subject": "this is message from PHP code",
"from_email": "YYY@inwise.com",
"reply_to": "noreply@inwise.com",
"from_name": "from me",
"charset": "utf-8",
"content_type": "html",
"to": [
{
"email": "YYY@inwise.com",
"name": "YYY",
"type": "to"
}
]
}
DATA;

curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

$resp = curl_exec($curl);
curl_close($curl);
var_export($resp);
?>

How can we help?