Create Email Message (post)
Create Email Message (post) | Create a new email message.
<?php //example PHP code to add an email message //set values of email message to insert $post_params['apiKey']="APIKEY_HERE"; $post_params['fromid']="FROMID_HERE"; //Id of email address to send email from. $post_params['subject']="SUBJECT_HERE"; //Subject of the email message. Max length is 500 characters. $post_params['emailhtml']="EMAILHTML_HERE"; //The text/html version of the email message. //Optional fields commented out below: //$post_params['emailname']="EMAILNAME_HERE"; //A reference name for the email, used in reporting. Max length is 255 characters. //$post_params['emailplain']="EMAILPLAIN_HERE"; //The plain/text version of the email. //$post_params['emailaol']="EMALAOL_HERE"; //The mobile version of the email. //$post_params['templateflag']="0"; //0=Not a template, 1=Is a template. Defaults to 0. //$post_params['mastertemplateid']="0"; //Id of the master template. Defaults to 0. //$post_params['folderid']="0"; //Id of the message folder. Defaults to 0. $url = 'http://apidomain.com/api2/messages/email'; //Posts this using CURL $curl = curl_init($url); curl_setopt ($curl, CURLOPT_POST, 1); curl_setopt ($curl, CURLOPT_POSTFIELDS, $post_params); curl_setopt ($curl, CURLOPT_CONNECTTIMEOUT, 100); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec ($curl); curl_close ($curl); echo $result; //Parse the json to get return values. $parsed_result = json_decode($result,false); echo "<br><br>Status: $parsed_result->status"; echo "<br>Message: $parsed_result->message"; echo "<br>Error Code: $parsed_result->errorcode"; echo "<br>Error Message: $parsed_result->errormessage"; echo "<br>Email Message Id: "; echo $parsed_result->data->id; echo "<br>Subject:"; echo $parsed_result->data->subject; echo "<br>Email Name:"; echo $parsed_result->data->emailname; ?>