Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagephp
// Schedule sending on Feb 26th 2015 at 15:55 UTC+2 
$EmailMessage->AddCustomHeader("X-SMTPAPI: {\"Schedule\":\"2015-02-26T15:55+02:00\"}");

Combine more options

Use commas as separator for the X-SMTPAPI parameters that you want to set.

Code Block
languagephp
// Schedule sending + Set Campaign Name & code
$EmailMessage->AddCustomHeader("X-SMTPAPI: {\"CampaignName\":\"Custom Aggregation 001\",\"CampaignCode\":\"Code001\",\"Schedule\":\"2015-02-26T15:55+02:00\"}");

Here below you can find an example of how you can send an email using SMTP Relay (SMTP+) from your client application.

It is a PHP snippet that requires PHPMailer and the credentials of a SMTP+ user.

Code Block
languagephp
titlePHP - Sending email using SMTP+
linenumberstrue
<?php
//########################################################
//Include the PHPmailer class.                 
//
//PHPmailer allows you to create and  transport an email an email message.                   
//The PHPmailer class is available at this address:
//https://github.com/PHPMailer/PHPMailer/ 
//########################################################
require_once "class.phpmailer.php";
$EmailMessage = new PHPmailer(); 
$EmailMessage->SetLanguage('en','language/');	//Define the language

//**********************************************
//SMTP configuration
//**********************************************
$EmailMessage->IsSMTP();	//Specify usage of SMTP Server
$EmailMessage->Host = "in.smtpok.com";	//SMTP+ Server address 
$EmailMessage->Port="25";	//SET the SMTP Server port               
$EmailMessage->Username = "smtpplus_username";	//SMTP+ authentication: username 
$EmailMessage->Password = "smtpplus_password";	//SMTP+ authentication: password       
$EmailMessage->SMTPAuth = true;	//Authentication required

//**********************************************
//Email data
//**********************************************
$EmailMessage->IsHTML(true);	//Set the email format
$EmailMessage->FromName= "myname";	//From: display name
$EmailMessage->From="sender_address@domain.com";	//From: email address
$EmailMessage->AddAddress("recipient_address@domail.com");	//Add one or more recipients
$EmailMessage->Subject="My first email sent via SMTP+";	//Set the email subject
$EmailMessage->Body="<b>Hello,<b><br/>This is my first email.";	//Set the email body
$EmailMessage->AltBody="Hello, This is my first email..";	//Set the email text part
 
//**********************************************
//Send the email
//**********************************************
if(!$EmailMessage->Send())
{ 
echo "<h1>Error sending the email.</h1>";	//Email was not sent
}
else
{
echo "Email has been sent";	//Mail sent
}                             

?>