note 23261 added to function.mail

From: Date: Sat, 13 Jul 2002 04:45:22 +0000
Subject: note 23261 added to function.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-33013@lists.php.net to get a copy of this message
I can for some unknown reason not send e-mail from PHP with qmail. No error message or anything. My workaround is the following function which is a drop-in for mail(). function qmail($to, $subject, $message, $header) { $email = "To: $to\n" //you could use ini_get("sendmail_from") for this address //or if you omit it qmail will insert user@domain . "From: sender@somewhere\n" . "Subject: $subject\n" . rtrim($header) . "\n\n" . $message; if ($filepointer = popen(ini_get("sendmail_path"), w)) { fputs($filepointer, $email, strlen($email)); pclose($filepointer); } else { //an error occured } } //example usage : qmail("reciever@somewhere", "Hello!", "How are you?", ""); I hope this can be of use to someone. I'm using PHP 4.2.1 as a Apache 2 filter together with qmail 1.03 on Linux. /Max Landborn -- http://www.php.net/manual/en/function.mail.php http://master.php.net/manage/user-notes.php?action=edit+23261 http://master.php.net/manage/user-notes.php?action=delete+23261 http://master.php.net/manage/user-notes.php?action=reject+23261

« previous php.notes (#33013) next »