note 23684 modified in function.mail by aidan
| From: | aidan@php.net | Date: | Mon, 14 Feb 2005 02:01:51 +0000 |
| Subject: | note 23684 modified in function.mail by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-84974@lists.php.net to get a copy of this message | ||
This can be used in place of mail()
<?php
function sendmail($to='', $subject='', $message='',
$headers='', $extra='')
{
$fd = popen("/usr/sbin/sendmail -t $extra", 'w');
fputs($fd, "To: $to\n");
fputs($fd, "Subject: $subject\n");
fputs($fd, "X-Mailer: PHP4\n");
if ($headers) {
fputs($fd, "$headers\n");
}
fputs($fd, "\n");
fputs($fd, $message);
pclose($fd);
}
?>
--was--
The latest versions of PHP won't allow multiple arguments to be sent to sendmail. (Anything
after the first space character is ignored.) This function works around this limitation by talking
to sendmail directly using a pipe. Use this in place of mail() if you need to send multiple flags to
sendmail:
function sendmail($to='', $subject='', $message='',
$headers='', $extra='')
{
$fd = popen("/usr/sbin/sendmail -t $extra", 'w');
fputs($fd, "To: $to\n");
fputs($fd, "Subject: $subject\n");
fputs($fd, "X-Mailer: PHP4\n");
if ($headers)
fputs($fd, "$headers\n");
fputs($fd, "\n");
fputs($fd, $message);
pclose($fd);
}
http://php.net/manual/en/function.mail.php