Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

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.

PHP - Sending email using SMTP+
<?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->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        


//**********************************************
//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
}                             

?>


 

 

 

  • No labels