Version: @(#) $Id: sendmail_message.php,v 1.18 2010/08/08 07:50:26 mlemos Exp $
MIME E-mail message composing and sending using Sendmail
Manuel Lemos (mlemos-at-acm.org)
Copyright © (C) Manuel Lemos 1999-2004
@(#) $Id: sendmail_message.php,v 1.18 2010/08/08 07:50:26 mlemos Exp $
Version: @(#) $Id: email_message.php,v 1.92 2011/01/28 06:32:16 mlemos Exp $
Implement an alternative message delivery method using Sendmail MTA (Mail Transfer Agent). This class can also be used with other MTAs like Exim, Postfix and Qmail, as they provide a wrapper commands that emulate the sendmail command.
This class should be used exactly the same way as the base class for composing and sending messages. Just create a new object of this class as follows and set only the necessary variables to configure details of delivery using Sendmail.
$message_object = new sendmail_message_class;
- Tuning the delivery mode for mass mailing
Sendmail supports several message delivery modes. In many installations the default is to attempt to deliver the message right away when the message is handed by the applications to Sendmail.
This may be an inconvenient because it makes PHP scripts wait for the message to be delivered to the destination SMTP server. If the SMTP connection with that server is slow, it may stall the delivery for a long while.
Under Unix/Linux, PHP defaults to using Sendmail or equivalent to deliver messages sent with the mail() function. Some people assume that it is faster to queue messages by relaying to an intermediate SMTP server than to use the mail() function that uses Sendmail. This is not accurate.
Sendmail supports other message delivery modes that can be used for much faster message queueing. These modes are more recommended for mass mailing. Adjust the value of the delivery_mode variable to improve the message queueing rate if you want to use this class for mass mailing.
Alternatively, you may also call the SetBulkMail to hint this class to use a delivery mode more suitable for bulk mailing. Currently, this makes this class use the delivery mode specified by the bulk_mail_delivery_mode variable, which defaults to make the messages be queued for later delivery, thus making the calling script execute much faster.
Specifying the path of the sendmail executable program.
The original default path of the sendmail used to be /usr/lib/sendmail. However, currently it is usually located in /usr/sbin/sendmail having a symbolic link pointing to that path from /usr/lib/sendmail.
If this symbolic link does not exist or the sendmail is different in your installation, you need to change this variable.
Specify the Sendmail message delivery mode. These delivery modes are only supported by Sendmail and Exim MTAs.
Current versions of Qmail and Postfix do not support configurable delivery modes. They always inject the messages in the local queue and let their queue management system take care of the delivery as soon as possible. Just leave this variable with the default value when using this class with these MTAs.
Sendmail supports several different delivery modes:
SENDMAIL_DELIVERY_DEFAULT - ''
Does not override the default mode.
SENDMAIL_DELIVERY_INTERACTIVE - 'i'
Attempt to send the messages synchronously to the recipient's SMTP server and only returns when it succeeds or fails. This is usually the default mode. It stalls the delivery of messages but it may be safer to preserve disk space because the successfully delivered messages are not stored.
SENDMAIL_DELIVERY_BACKGROUND - 'b'
Creates a background process that attempts to deliver the message and returns immediately. This mode is recommended when you want to send a few messages as soon as possible. It is not recommended for sending messages to many recipients as it may consume too much memory and CPU that result from creating excessive background processes.
SENDMAIL_DELIVERY_QUEUE - 'q'
Just drop the message in the queue and leave it there until next time the queue is run. It is recommended for deliverying messages to many recipients as long as there is enough disk space to store all the messages in the queue.
SENDMAIL_DELIVERY_DEFERRED - 'd'
The same as the queue mode except for a few verifications that are skipped.
Specify the Sendmail message delivery mode when the class is in bulk mail mode that is set with the SetBulkMail function.
The available delivery modes are the same as those used to set the delivery_mode variable. The default bulk mail delivery mode is to just queue the message (SENDMAIL_DELIVERY_QUEUE) without waiting for sendmail to deliver the message.
Note that some MTAs that emulate Sendmail return an error when set to queue delivery mode. If this happens with the MTA that you are using, change this variable to the SENDMAIL_DELIVERY_DEFAULT.
Specify additional sendmail program arguments.
Use this to to pass additional arguments that are not supported by this class.
'sendmail $Revision: 1.18 $'
Specify the text that is used to identify the mail delivery class or sub-class. This text is appended to the X-Mailer header text defined by the mailer variable.
Do not change this variable.