Email Send (post)
Email Send (post) | Send an Email
<?php //example PHP code to send an email //set values for email $post_params['apiKey']="APIKEY_HERE"; $post_params['from']="example@email.com"; $post_params['to']="example@email.com"; $post_params['subject']="SUBJECT_HERE"; $post_params['bodyhtml']="HTMLBODY_HERE"; //Optional fields commented out below: //$post_params['bodytext']="TEXTBODY_HERE"; //$post_params['cc']="To Name <example@email.com>"; //$post_params['bcc']="example1@email.com,example2@email.com,example3@email.com"; //$post_params['replyto']="example@email.com"; //$post_params['emailname']="EMAILNAME_HERE"; //$post_params['tracklinks']="false"; //$post_params['trackopens']="false"; //$post_params['headers']='{"X-Accept-Language": "en", "X-Mailer": "MyApp"}'; $url = 'http://apidomain.com/api2/email/send'; //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"; ?>
Email Send (post) | Send an Email with Attachment
<?php //example PHP code to send an email with a file attachment //set values for email $post_params['apiKey']="APIKEY_HERE"; $post_params['from']="example@email.com"; $post_params['to']="example@email.com"; $post_params['subject']="SUBJECT_HERE"; $post_params['bodyhtml']="HTMLBODY_HERE"; $post_params['file'] = "@/path/to/myfile.jpg"; //Optional fields commented out below: //$post_params['bodytext']="TEXTBODY_HERE"; //$post_params['cc']="To Name <example@email.com>"; //$post_params['bcc']="example1@email.com,example2@email.com,example3@email.com"; //$post_params['replyto']="example@email.com"; //$post_params['emailname']="EMAILNAME_HERE"; //$post_params['tracklinks']="false"; //$post_params['trackopens']="false"; //$post_params['headers']='{"X-Accept-Language": "en", "X-Mailer": "MyApp"}'; $url = 'http://apidomain.com/api2/email/send'; //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"; ?>