function sendmail($from_name,$from_address,$to_address,$subject,$message,$additional_headers='') { $MSG = "Return-Path: <$from_address>\n"; $MSG .= "To: $to_address\n"; $from = $from_address; if (!empty($from_name)) $from = "$from_name <$from>"; $MSG .= "From: $from\n"; $ZONE = Date('Z'); $SIGN = '+'; if ($ZONE > 0) $SIGN = '-'; $ZONE = abs($ZONE); $MSG .= 'Date: '.Date('D, d M Y H:i:s ').$SIGN.sprintf('%02d%02d',floor($ZONE/3600),floor(($ZONE%3600)/60))."\n"; if (!empty($subject)) $MSG .= "Subject: $subject\n"; $MSG .= "$additional_headers\n"; $MSG .= "\n"; $MSG .= $message; $fp = popen('/usr/sbin/sendmail -t','w'); $num = fputs($fp,$MSG); pclose($fp); return $num; } |