function pun_mail($to, $subject, $message, $reply_to_email = '', $reply_to_name = '') { global $pun_config, $lang; // Default sender/return address $from_name = $lang->t('Mailer', $pun_config['o_board_title']); $from_email = $pun_config['o_webmaster_email']; // Do a little spring cleaning $to = pun_trim(preg_replace('%[\\n\\r]+%s', '', $to)); $subject = pun_trim(preg_replace('%[\\n\\r]+%s', '', $subject)); $from_email = pun_trim(preg_replace('%[\\n\\r:]+%s', '', $from_email)); $from_name = pun_trim(preg_replace('%[\\n\\r:]+%s', '', str_replace('"', '', $from_name))); $reply_to_email = pun_trim(preg_replace('%[\\n\\r:]+%s', '', $reply_to_email)); $reply_to_name = pun_trim(preg_replace('%[\\n\\r:]+%s', '', str_replace('"', '', $reply_to_name))); // Set up some headers to take advantage of UTF-8 $from = '"' . encode_mail_text($from_name) . '" <' . $from_email . '>'; $subject = encode_mail_text($subject); $headers = 'From: ' . $from . "\r\n" . 'Date: ' . gmdate('r') . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-transfer-encoding: 8bit' . "\r\n" . 'Content-type: text/plain; charset=utf-8' . "\r\n" . 'X-Mailer: FluxBB Mailer'; // If we specified a reply-to email, we deal with it here if (!empty($reply_to_email)) { $reply_to = '"' . encode_mail_text($reply_to_name) . '" <' . $reply_to_email . '>'; $headers .= "\r\n" . 'Reply-To: ' . $reply_to; } // Make sure all linebreaks are LF in message (and strip out any NULL bytes) $message = str_replace("", '', pun_linebreaks($message)); if ($pun_config['o_smtp_host'] != '') { // Headers should be \r\n // Message should be ?? $message = str_replace("\n", "\r\n", $message); smtp_mail($to, $subject, $message, $headers); } else { // Headers should be \r\n // Message should be \n mail($to, $subject, $message, $headers); } }
function pun_mail($to, $subject, $message, $reply_to_email = '', $reply_to_name = '') { global $feather_config, $lang_common; // Use \r\n for SMTP servers, the system's line ending for local mailers $smtp = $feather_config['o_smtp_host'] != ''; $EOL = $smtp ? "\r\n" : FORUM_EOL; // Default sender/return address $from_name = sprintf($lang_common['Mailer'], $feather_config['o_board_title']); $from_email = $feather_config['o_webmaster_email']; // Do a little spring cleaning $to = feather_trim(preg_replace('%[\\n\\r]+%s', '', $to)); $subject = feather_trim(preg_replace('%[\\n\\r]+%s', '', $subject)); $from_email = feather_trim(preg_replace('%[\\n\\r:]+%s', '', $from_email)); $from_name = feather_trim(preg_replace('%[\\n\\r:]+%s', '', str_replace('"', '', $from_name))); $reply_to_email = feather_trim(preg_replace('%[\\n\\r:]+%s', '', $reply_to_email)); $reply_to_name = feather_trim(preg_replace('%[\\n\\r:]+%s', '', str_replace('"', '', $reply_to_name))); // Set up some headers to take advantage of UTF-8 $from = '"' . encode_mail_text($from_name) . '" <' . $from_email . '>'; $subject = encode_mail_text($subject); $headers = 'From: ' . $from . $EOL . 'Date: ' . gmdate('r') . $EOL . 'MIME-Version: 1.0' . $EOL . 'Content-transfer-encoding: 8bit' . $EOL . 'Content-type: text/plain; charset=utf-8' . $EOL . 'X-Mailer: FeatherBB Mailer'; // If we specified a reply-to email, we deal with it here if (!empty($reply_to_email)) { $reply_to = '"' . encode_mail_text($reply_to_name) . '" <' . $reply_to_email . '>'; $headers .= $EOL . 'Reply-To: ' . $reply_to; } // Make sure all linebreaks are LF in message (and strip out any NULL bytes) $message = str_replace("", '', feather_linebreaks($message)); $message = str_replace("\n", $EOL, $message); $mailer = $smtp ? 'smtp_mail' : 'mail'; $mailer($to, $subject, $message, $headers); }