I’m trying to make a new email with the API. I’m using the code below. I get no errors, but the email doesn’t get created. If I use the API with the same user (the user has full permissions for the purpose of testing), the API will create a user. It doesn’t create an email for testing, however.
function makeEmail() {
$loginname = 'login';
$password = 'sectet';
$siteurl = 'my.mautic.com';
$curl = curl_init();
// Set some options - we are passing in a user agent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => "https://".$loginname.":".$password."@".$siteurl."/api/emails/new",
CURLOPT_USERAGENT => 'Mautic Email Maker',
CURLOPT_POST => 1,
// posting the payload
CURLOPT_POSTFIELDS => array(
'fromName' => 'Joe',
'name' => 'The email name',
'subject' => 'I am the subject',
'language' => 'English',
'emailType' => 'list',
'isPublished' => 0,
'customHtml' => '<h1> Hello World </h1>',
'plainText' => '',
'createdBy' => 1,
'createdByUser' => 'Auto',
'category' => null,
'useOwnerAsMailer' => 0,
'lists[]' => 1,
'publishUp' => date("Y-m-d").' 16:00:00',
'publishDown' => date("Y-m-d").' 18:00:00',
'unsubscribeForm' => null
)
));
curl_exec($curl);
}
makeEmail();
?>