Sending Attachments via API

Here’s an example of sending an attachment via the SendTransactionalEmail API method using PHP.

  'your username',
 'Password' =>  'your password',
 'FromEmail' => 'your FROM address',
 'FromName' =>  'your FROM name',
 'ToEmailAddress' => 'your TO recipient',
 'ToHeader' => 'your TO recipient repeated here for the header',
 'ContentType' => $content_type,
 'Subject' =>   'Testing an attachment ' . $date,
 'RawMessage' => $rawmessage,
 'Options' => 'OpenTrack=True,ClickTrack=True'
);

// Call the API method
$ch = curl_init('https://api.jangomail.com/api.asmx/SendTransactionalEmailRaw');

// Set cURL options
curl_setopt($ch,CURLOPT_POST,count($post_array));
curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($post_array));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

echo 'Calling execute: '." ".date('m/d/Y h:i:s a', time());
// Execute
$response = curl_exec($ch);

// Close request
curl_close($ch);

// Output results
    ob_start();
    var_dump($response) ;
    $dump = ob_get_contents();
    ob_end_clean();

$enddate = time();

//print 'Start is ' . $date . ' and end is ' . $enddate;
$elapsed = $enddate - $date;
echo substr($dump,104,12) . ' Elapsed time: ' .$elapsed . "\n";
//printf('Elapsed time is %u;',$elapsed);

?>