The class enables you to send emails with attachments, embedded images, html, or just plain-text via SMTP or using PHP's native mail function.

This is the constructor for the class, and it creates an email object.

$from The email address of the sender. To include your name make it an array. The default is your servers configuration 'sendmail_from' value.
$debug Set to true if you're just testing the waters, and want to see what is going on.
$email = new Mailer (array('Yours Truly'=>''), true);

Connects you to your SMTP server. Once you're in, you can send as many emails as you like without connecting over and over again. SMTP is much more reliable than mail(), and if this method returns true you can be confident that your email was sent and will be received. If you don't use this, or if you don't check to make sure that this method worked, then your email will be sent using PHP's native mail() function.

$server Your outgoing (SMTP) server. The default is 'localhost'.
$port The port to connect to. The default is 25.
$username Your username.
$password Your password.
Returns True if successful, false if not.
if ($email->smtp('', 25)) { // Proceed . . .

This will include an attachment to your email, and you can call this method as many times as you like.

$filename The name of the file.
$filepath The full server path to the attachments directory. Don't forget the trailing slash.
$email->attach ('report.pdf', '/base/directory/');

Just as advertised. When you include the directory to the images contained in your html, it will embed them in your email. Just keep calling this method for every email you want to send.

$to The email address of the receiver. To include their name make it an array:
$to['Their Name'] = '';
$subject The subject of the email.
$text The body of your message. You don't need to worry about newlines ("\n\n") - it will take either newlines, or <br /> tags.
$html To display an html message. The $text string above is not needed if you declare this, but it is recommended for good form anyways.
$images The full server path to where the images in your email reside. Don't forget the trailing slash.
Returns True if successful, false if not.
$to = ''; 
$subject = 'Friendly Reminder'; 
$text = 'Tell your friends about me!'; 
$page = new Page ('Friendly Reminder'); 
$html = $page->display ('<img src="logo.gif" /><br />Tell your friends about me!'); 
unset ($page); 
$email->send($to, $subject, $text, $html, '/base/directory/');

This will close your open SMTP connection, and you should call this method after you $email->send() everything.


Did some of your emails not get sent? Want to know what is going on so you can figure out what to do about it? This method will send you an informational array of all your interactions with SMTP, the expected responses in parentheses, and the actual response you were given.

Returns An array of SMTP status codes.