function txpMail($to_address, $subject, $body, $reply_to = null) { global $txp_user, $prefs; // if mailing isn't possible, don't even try if (is_disabled('mail')) { return false; } // Likely sending passwords if (isset($txp_user)) { extract(safe_row('RealName, email', 'txp_users', "name = '" . doSlash($txp_user) . "'")); } else { extract(safe_row('RealName, email', 'txp_users', "email = '" . doSlash($to_address) . "'")); } if ($prefs['override_emailcharset'] and is_callable('utf8_decode')) { $charset = 'ISO-8859-1'; $RealName = utf8_decode($RealName); $subject = utf8_decode($subject); $body = utf8_decode($body); } else { $charset = 'UTF-8'; } $RealName = encode_mailheader(strip_rn($RealName), 'phrase'); $subject = encode_mailheader(strip_rn($subject), 'text'); $email = strip_rn($email); if (!is_null($reply_to)) { $reply_to = strip_rn($reply_to); } $sep = !IS_WIN ? "\n" : "\r\n"; $body = str_replace("\r\n", "\n", $body); $body = str_replace("\r", "\n", $body); $body = str_replace("\n", $sep, $body); $headers = "From: {$RealName} <{$email}>" . $sep . 'Reply-To: ' . (isset($reply_to) ? $reply_to : "{$RealName} <{$email}>") . $sep . 'X-Mailer: Textpattern' . $sep . 'Content-Transfer-Encoding: 8bit' . $sep . 'Content-Type: text/plain; charset="' . $charset . '"' . $sep; if (is_valid_email($prefs['smtp_from'])) { if (IS_WIN) { ini_set('sendmail_from', $prefs['smtp_from']); } elseif (!ini_get('safe_mode')) { return mail($to_address, $subject, $body, $headers, '-f' . $prefs['smtp_from']); } } return mail($to_address, $subject, $body, $headers); }
function txpMail($to_address, $subject, $body, $reply_to = null) { global $txp_user, $prefs; // Likely sending passwords if (isset($txp_user)) { extract(safe_row('RealName, email', 'txp_users', "name = '" . doSlash($txp_user) . "'")); } else { extract(safe_row('RealName, email', 'txp_users', "email = '" . doSlash($to_address) . "'")); } if ($prefs['override_emailcharset'] and is_callable('utf8_decode')) { $charset = 'ISO-8859-1'; $RealName = utf8_decode($RealName); $subject = utf8_decode($subject); $body = utf8_decode($body); } else { $charset = 'UTF-8'; } $RealName = encode_mailheader(strip_rn($RealName), 'phrase'); $subject = encode_mailheader(strip_rn($subject), 'text'); $email = strip_rn($email); if (!is_null($reply_to)) { $reply_to = strip_rn($reply_to); } if (!is_callable('mail')) { return false; } else { $sep = !is_windows() ? "\n" : "\r\n"; $body = str_replace("\r\n", "\n", $body); $body = str_replace("\r", "\n", $body); $body = str_replace("\n", $sep, $body); return mail($to_address, $subject, $body, "From: {$RealName} <{$email}>" . $sep . 'Reply-To: ' . (isset($reply_to) ? $reply_to : "{$RealName} <{$email}>") . $sep . 'X-Mailer: Textpattern' . $sep . 'Content-Transfer-Encoding: 8bit' . $sep . 'Content-Type: text/plain; charset="' . $charset . '"' . $sep); } }