Answer the question
In order to leave comments, you need to log in
What is the correct way to send html to json via curl?
Good evening!
I send mail via unione, I ran into a problem sending mail in html format.
Here is part of my code:
$json = '
{
"api_key": "'.$api_key.'",
"message":
{
"global_substitutions":
{
"someVar":"body.html"
},
"body":
{
"html": "'.$message.'"
},
"subject": "'.$subject.'",
"from_email": "'.$from.'",
"from_name": "NAME",
"reply_to": "'.$reply.'",
"track_links" : 1,
"track_read" : 1,
"recipients": [
{
"email": "'.$to.'"
}
]
}
}
';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$result = curl_exec($ch);
Answer the question
In order to leave comments, you need to log in
$json = json_encode([
"api_key" => $api_key,
"message" => [
"global_substitutions" => [
"someVar" => "body.html"
],
"body" => [
"html" => $message
],
"subject" => $subject,
"from_email" => $from,
"from_name" => "NAME",
"reply_to" => $reply,
"track_links" => 1,
"track_read" => 1,
"recipients": [
["email" => $to]
]
]
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question