function send_mail($email, $subject, $message, $from = "", $reply_to = "", $html_template = "", $templatevars = null, $from_name = "", $cc = "", $bcc = "") { # Send a mail - but correctly encode the message/subject in quoted-printable UTF-8. # NOTE: $from is the name of the user sending the email, # while $from_name is the name that should be put in the header, which can be the system name # It is necessary to specify two since in all cases the email should be able to contain the user's name. # old mail function remains the same to avoid possible issues with phpmailer # send_mail_phpmailer allows for the use of text and html (multipart) emails, # and the use of email templates in Manage Content global $always_email_from_user; if ($always_email_from_user) { global $username, $useremail, $userfullname; $from_name = $userfullname != "" ? $userfullname : $username; $from = $useremail; $reply_to = $useremail; } global $always_email_copy_admin; if ($always_email_copy_admin) { global $email_notify; $bcc .= "," . $email_notify; } # Send a mail - but correctly encode the message/subject in quoted-printable UTF-8. global $use_phpmailer; if ($use_phpmailer) { send_mail_phpmailer($email, $subject, $message, $from, $reply_to, $html_template, $templatevars, $from_name, $cc, $bcc); return true; } # No email address? Exit. if (trim($email) == "") { return false; } # Include footer global $email_footer; global $disable_quoted_printable_enc; # Work out correct EOL to use for mails (should use the system EOL). if (defined("PHP_EOL")) { $eol = PHP_EOL; } else { $eol = "\r\n"; } $message .= $eol . $eol . $eol . $email_footer; if ($disable_quoted_printable_enc == false) { $message = rs_quoted_printable_encode($message); $subject = rs_quoted_printable_encode_subject($subject); } global $email_from; if ($from == "") { $from = $email_from; } if ($reply_to == "") { $reply_to = $email_from; } global $applicationname; if ($from_name == "") { $from_name = $applicationname; } if (substr($reply_to, -1) == ",") { $reply_to = substr($reply_to, 0, -1); } $reply_tos = explode(",", $reply_to); # Add headers $headers = ""; #$headers .= "X-Sender: x-sender" . $eol; $headers .= "From: "; #allow multiple emails, and fix for long format emails for ($n = 0; $n < count($reply_tos); $n++) { if ($n != 0) { $headers .= ","; } if (strstr($reply_tos[$n], "<")) { $rtparts = explode("<", $reply_tos[$n]); $headers .= $rtparts[0] . " <" . $rtparts[1]; } else { mb_internal_encoding("UTF-8"); $headers .= mb_encode_mimeheader($from_name, "UTF-8") . " <" . $reply_tos[$n] . ">"; } } $headers .= $eol; $headers .= "Reply-To: {$reply_to}" . $eol; if ($cc != "") { global $userfullname; #allow multiple emails, and fix for long format emails $ccs = explode(",", $cc); $headers .= "Cc: "; for ($n = 0; $n < count($ccs); $n++) { if ($n != 0) { $headers .= ","; } if (strstr($ccs[$n], "<")) { $ccparts = explode("<", $ccs[$n]); $headers .= $ccparts[0] . " <" . $ccparts[1]; } else { mb_internal_encoding("UTF-8"); $headers .= mb_encode_mimeheader($userfullname, "UTF-8") . " <" . $ccs[$n] . ">"; } } $headers .= $eol; } if ($bcc != "") { global $userfullname; #add bcc $bccs = explode(",", $bcc); $headers .= "Bcc: "; for ($n = 0; $n < count($bccs); $n++) { if ($n != 0) { $headers .= ","; } if (strstr($bccs[$n], "<")) { $bccparts = explode("<", $bccs[$n]); $headers .= $bccparts[0] . " <" . $bccparts[1]; } else { mb_internal_encoding("UTF-8"); $headers .= mb_encode_mimeheader($userfullname, "UTF-8") . " <" . $bccs[$n] . ">"; } } $headers .= $eol; } $headers .= "Date: " . date("r") . $eol; $headers .= "Message-ID: <" . date("YmdHis") . $from . ">" . $eol; #$headers .= "Return-Path: returnpath" . $eol; //$headers .= "Delivered-to: $email" . $eol; $headers .= "MIME-Version: 1.0" . $eol; $headers .= "X-Mailer: PHP Mail Function" . $eol; if (!is_html($message)) { $headers .= "Content-Type: text/plain; charset=\"UTF-8\"" . $eol; } else { $headers .= "Content-Type: text/html; charset=\"UTF-8\"" . $eol; } $headers .= "Content-Transfer-Encoding: quoted-printable" . $eol; mail($email, $subject, $message, $headers); }
// We check in which language we will work if (isset($_SESSION["DATAGLOBAL"][0]) && !empty($_SESSION["DATAGLOBAL"][0])) { $C->LANGUAGE = $_SESSION["DATAGLOBAL"][0]; } $this->load_langfile('outside/home.php'); $errored = 0; $txterror = ''; $em = ''; if (isset($_POST["em"]) && $_POST["em"] != '') { $em = $this->db1->e($_POST["em"]); } if (empty($em)) { $errored = 1; $txterror .= 'Error... '; } if ($errored == 1) { echo "0: " . $txterror; } else { $codeuser = $this->db2->fetch_field("SELECT code FROM users WHERE email='" . $em . "' LIMIT 1"); if (!$codeuser) { echo '0: ' . $this->lang('home_f_recovery_error2'); } else { $coderecovery = getCode(20, 0); $this->db2->query("UPDATE users SET coderecovery='" . $coderecovery . "' WHERE code='" . $codeuser . "' LIMIT 1"); $D->linkresetpass = $C->SITE_URL . 'login/resetpass/c:' . $coderecovery . '/cu:' . $codeuser; $message = $this->load_template('__mail_resetpass.php', FALSE); $subject = $this->lang('home_f_recovery_em_subject', array('#SITE_TITLE#' => $C->SITE_TITLE)); send_mail_phpmailer($em, $subject, $message); echo '1: ' . $this->lang('home_f_recovery_ok'); } }