XPertMailer is a PHP class that you can use to send encoded MIME type e-mail messages (text, HTML, HTML embedded images, attachments) towards a localhost, client or relay SMTP servers with optional authorisation. Cc and Bcc functionality are included.
The XPertMailer class functions are optimised to execute in a very small time and allso to be easy to use. This reduces the size of the code and the time required to write it.
The names of the public functions in the XPertMailer class are eloquent so that they can be used without any confusions being made.
The data sendig is done according to the RFC 821 and RFC 2821, and the message type is in conformity with the RFC 2045, RFC 2046, RFC 2047, RFC 2048, RFC 2049, and RFC 2822.
A simple example how to use:
PHP Code:
<?php
set_time_limit(0);
// optionaly, you can disable display errors
error_reporting(false); // from php (generally)
define('PRINT_ERROR', false); // from XPertMailer class
// path to XPertMailer class file
require_once 'XPertMailer.php';
/**
* send to multiple e-mail addresses - text/html format
* with two HTML embedded images and two attachment files
* --------------------------------------
*/
// optionaly, you can use an relay host name, if fail, send directly to the client
$mail = new XPertMailer(SMTP_RELAY_CLIENT, 'relay-host-name.com');
// set authentication username and password for relay host and auth type (here AUTH_LOGIN, by default is AUTH_DETECT)
$mail->auth('username', 'password', AUTH_LOGIN);
// optionaly, set the port number value for SMTP server socket connections, default are 25
$mail->port(25);
// optionaly, set time out for SMTP server socket connections (in secounds), default are 10
$mail->timeout(30);
// set priority high (default is normal)
$mail->priority(P_HIGH);
// set from mail address and optionaly from name
$mail->from('my@account.com', 'My Name');
// set each header name and value
$header['Cc'] = 'user1@example1.com, anotheruser1@example2.com';
$header['Bcc'] = 'user2@example3.com, anotheruser2@example4.com';
$header['Reply-To'] = 'reply@domain.com';
$header['X-Whatever'] = 'description';
// set additional header informations
$mail->headers($header);
// set HTML embedded images name and optionaly you can rename them
// if the file is not in this directory, write the path name (/path/name.image_extension)
// Attention: do not include path name in the rename file like /path/rename.gif, put only rename.gif
$imgs[] = 'image1.jpg';
$imgs['rename.gif'] = 'image2.gif';
// attach HTML embedded images
$mail->attach($imgs, ATTACH_HTML_IMG);
// set attachment files name and optional you can rename them
// if the file is not in this directory, write the path name (/path/name.file_extension)
$file['new.zip'] = 'archive1.zip';
$file[] = 'archive2.tar.gz';
// attach files
$mail->attach($file, ATTACH_FILE);
// set html value
// Attention: do not include image path name in HTML source like <img src="/path/name.jpg">, put only <img src="name.jpg">
$html = '<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
<html>
<body>
<img src="image1.jpg" border="0"><br>
<b><u><i>next image</i></u></b> :-)<br>
<img src="rename.gif" border="2"><br>
<font color="red">message html red here</font>
</body>
</html>';
// send to multiple e-mail addresses and optionaly you can set charset value (here UTF-8, by default is ISO-8859-1)
// as you can see, the text/plain message is required because not all mail clients can currently support HTML messages
$send = $mail->send('touser@domain1.com, toanotheruser@domain2.com', 'subject here', 'text version'.CRLF.'new line', $html, 'UTF-8');
// compare the result and print a message
echo $send ? "Done." : "Error.";
// some useful for debugging
echo "<br>Server response: ".$mail->response;
?>
For more informations, visit: www.xpertmailer.com
Bookmarks