note 32577 deleted from ref.mail by kennyt
| From: | kennyt@php.net | Date: | Sun, 18 Jul 2004 17:40:00 +0000 |
| Subject: | note 32577 deleted from ref.mail by kennyt | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-73535@lists.php.net to get a copy of this message | ||
Note Submitter: Tomislav Drpic - www.ilatina.com/tdrpic/
----
While working with a system that would send a lot of emails, I wanted to skip the local antivirus
program (Amavis with local relay virus check) so that sending the emails won't load the server
heavily. Also, I needed to change the "Return-path:" header of the message.
This is the solution I came up with:
<?php
$messg = "Here we put the content of the message.";
$sender = "email@example.com";
$sendmail = "/usr/sbin/sendmail -t -f $sender -C /etc/sendmail.orig.cf";
/*
Notice that sendmail is receiving three params:
-t
Scan the To:, Cc:, and Bcc: from the message itself
-f <email address>
Change the envelope (Return-path:) of the message
-C <config path>:
Use a different configuration file for sendmail, in this case the config file
skips the virus check
*/
$fd = popen($sendmail, "w");
fputs($fd, "To: recipient@example.com\r\n");
fputs($fd, "From: \"Sender Name\" <$sender>\r\n");
fputs($fd, "Subject: Finally\r\n");
fputs($fd, "X-Mailer: Mailer Name\r\n\r\n");
fputs($fd, $body);
pclose($fd);
?>
Notice that this script will be called from a cron job as root (sendmail won't let you use a
different config file unless you are root).