What We Do
We provide top quality services and best solutions based on your requirements and needs.
Share

How to send mail using MXAE API

Sometimes there is a need to send email out programmatically during your course of your website development. MXAE provides an easy way to obtain an SMTP object via API for developer to send email out from the website. This mxSMTP object obtained is pre-instantiated based on the SMTP settings set within the website property hence the developer does not need to know anything about the website's SMTP settings. 

Example:

<?php
// get the mxSMTP object
$smtp = mxApp::getInstance()->getSMTPObject();
$headers['Content-Type'] = 'text/html';
$emails = array('user1@test.com', 'user2@test.com');
$smtp->setRecipient($emails);
$from = 'Example Email';
$body = 'Following is the detail of the article you have just submitted:<br/><br/>'."\n";
$body .= '<table cellpadding="2" cellspacing="0" border="0">'."\n";
$body .= '<tr><td>ID</td><td>:</td><td><b>'.$article->id.'</b></td></tr>'."\n";
$body .= '<tr><td>Date</td><td>:</td><td><b>'.$article->pubdate.'</b></td></tr>'."\n";
$body .= '<tr><td>Title</td><td>:</td><td><b>'.htmlspecialchars($article->title).'</b></td></tr>'."\n";
$body .= '<tr><td>Summary</td><td>:</td><td><b>'.htmlspecialchars($article->body).'</b></td></tr>'."\n";
$body .= '<tr><td>Country</td><td>:</td><td><b>'.htmlspecialchars($article->country).'</b></td></tr>'."\n";
$body .= '</table>'."\n";
$smtp->setHTMLBody($body);
$this->log('Sending email...');
if (!$smtp->send($from, '[NOTE] '.$article->title, $headers)) {
	$this->log("Error sending email: ".$smtp->getLastErrorMessage(), MX_LOG_ERROR);
}
?>
For information on mxSMTP object, refer to the MXAE API online reference.

MXAE Release News

MXAE 2.7.5 Released
We would like to announce the immediate availability of MXAE 2.7.5. This release focuses on...




Tips & Tricks

How to send mail using MXAE API
Sometimes there is a need to send email out programmatically during your course of your website...




MXAE Free Hosting

We are offering FREE hosting on MXAE platform with no string attached. You can use it as a development or demo hosting for your company. You can also use it to build your own website or host your client website.