note 4304 deleted from function.mail by jimw

From: Date: Wed, 31 Oct 2001 22:59:13 +0000
Subject: note 4304 deleted from function.mail by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-19848@lists.php.net to get a copy of this message
Want to know how to configure the Return-Path header? Say that you usually send mail with the PHP mail() function as such: mail($toaddress,$subject,$body,$headers); where $headers includes "From: $fromaddress\n" among other things. use this function <pre> function mailfrom($fromaddress, $toaddress, $subject, $body, $headers) { $fp = popen('/usr/sbin/sendmail -f'.$fromaddress.' '.$toaddress,"w"); if(!$fp) return false; fputs($fp, "To: $toaddress\n"); fputs($fp, "Subject: $subject\n"); fputs($fp, $headers."\n\n"); fputs($fp, $body); fputs($fp, "\n"); pclose($fp); return true; } </pre> Make sure that special characters are removed from $toaddress and $fromaddress as they are being passed to the shell. The email validation function from the PHP mailing list does a good job of removing them, except for backtick (`). The return value of the function is basically meaningless as sendmail sends errors to STDIO and I don't know how to handle that. Also, this may insert an X-Authentication-Warning header in your email.

« previous php.notes (#19848) next »