PHPMailer Example
Below is an example of using PHPMailer
<?php
// phpmailer-example.php
// Inject a single test message into Kasplo Engine using PHPMailer
// Use PHPMailer
require_once('/usr/share/php/PHPMailer/class.phpmailer.php');
require_once('/usr/share/php/PHPMailer/class.smtp.php');
$mail = new PHPMailer();
$mail->IsSMTP(); // tell the class to use SMTP
//$mail->SMTPDebug = 2; // uncomment to print debugging info
// Timezone
date_default_timezone_set('America/Chicago');
// Kasplo Engine installation settings
$mail->Host = "mta.example.com"; // Connect to this Kasplo server
$mail->SMTPAuth = true; // enables SMTP authentication. Set to false for IP-based authentication
$mail->Port = 587; // SMTP submission port to inject mail into. Usually port 587 or 25
$mail->Username = "smtpauth@example.com"; // SMTP username
$mail->Password = "password"; // SMTP password
// Campaign Settings
$mail_class = "transactional"; // Mail Class to use
$mail->SetFrom("test@example.com", "From Name");
$mail->Subject = PHPMailer Example";
$mail->MsgHTML("HTML body");
$mail->AltBody = "Text body";
// Individual Recipient Settings
$recipient = "recipient@example.com";
$recipient_name = "Recipient Name";
// Generate the To: and X-Kasplo-MailClass headers
$mail->AddAddress($recipient, $recipient_name);
$mail->addCustomHeader("X-Kasplo-MailClass: $mail_class");
// Send the campaign
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo . "\n";
} else {
echo "Message sent!\n";
}