SimpleMail :

  • Category : Sources
  • Status : In Progress
  • Type : Reflectiv Projects
  • Licence : GNU/GPLv3

Description :

SimpleMail makes the email sending easy in your PHP applications.

All you have to do is indicate the main elements (from, to, subject), and set a message. You can also add more details to your email (date, cci, etc) very easily.

You can add various type of message for the same email (in html AND plain text for example) and adding an attachment is as easy as adding a message !

Code :

<?php
require_once ('Email/SimpleMail.php');
require_once ('Compression/GzCompression.php');

try {
	$oEmail = new SimpleMail ();
	$oEmail->From = 'moi@example.org';
	$oEmail->To = array ('friend1@example.org', 'friend2@example.org');
	$oEmail->Bcc = array ('secretFriend@example.org');
	
	$oEmail->Subject = 'Nice Message';
	
	$oEmail->addBody ('This message is a plain text message, very simple !');
	$oEmail->addBody ('This message is in <b>html</b> format message, with some <u>special html tags</u>. You can also automatically add some <img src="image.png" alt="images" />. It\'s very simple !', 'text/html');

	$oEmail->addAttachment ('/var/www/myDoc.pdf', MimeType::get ('pdf')); // Basic file !
	$oEmail->addAttachment ('/var/www/myDoc.pdf', MimeType::get ('tgz'), 'myCompressedDoc.tgz', $oGzCompress); // Basic file !

	$oEmail->send ();

	echo 'You\'re message was sent';
}
catch (Exception $oE) {
	var_dump ($oE);
	echo 'An error occured during sending the message.<br />'.$oE->getMessage ();
}
?>