Mail

Mail -- An interface for sending EMails

Multiple backends

Mail supports different types of backends to send email. So two steps are necessary to send an email.

Mail supports three types of backends:

Mail::Factory()

mixed &factory (string $backend [, array $param = array()])

Description

creates a instance of a backend-specific mail class

Parameter

Return value

Notes

List of parameter for the backends

Mail_*::send()

mixed send (mixed $recipients, array $headers, string $body)

Description

Sends a mail. The send()-function is provided by the object returned from factory()

Parameter

Return value

Example

<?php
include('Mail.php');

$recipients = 'joe@example.com';

$headers['From']    = 'richard@phpguru.org';
$headers['To']      = 'joe@example.com';
$headers['Subject'] = 'Test message';

$body = 'Test message';

$params['sendmail_path'] = '/usr/lib/sendmail';

// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory('sendmail', $params);

$mail_object->send($recipients, $headers, $body);
?>