function send_mailer($a, $b, $c, $d = "", $e = "", $f = "", $g = "") { if (file_exists("../classes/mailer/class.phpmailer.php")) { require_once "../classes/mailer/class.phpmailer.php"; } $c = eregi_replace("[\\]", '', $c); $i = translate("Thông báo từ hott.vn"); $j = new PHPMailer(); $k = array(1 => "mta8.mailmytour.com", 2 => "mta6.mailmytour.com"); $m = array_rand($k); $j->IsSMTP(); $j->SMTPAuth = true; $j->Host = $k[$m]; $j->Port = 25; $j->From = "*****@*****.**"; $j->FromName = $i; $j->Username = "******"; $j->Password = "******"; $j->CharSet = "UTF-8"; $j->ContentType = "text/html"; $j->Subject = $b; $j->AddAddress($a); $j->Body = $c; if ($d != "") { $j->AddAttachment($d); } $j->IsHTML(true); $j->SMTPDebug = 1; $n = $j->Send(); $o = array(); $o["Host"] = $j->Host; $o["From"] = $j->FromName; $o["Email"] = $a; $o["subject"] = $j->Subject; $o["Error"] = $j->ErrorInfo; saveLog1("all_email", json_encode($o)); if (!$n) { if (strlen($e) <= 3) { } saveLog1("error_email", "Loi: " . $j->ErrorInfo); return false; } else { return true; } }
function send_mailer($to, $title, $content, $attach_file = "", $id_error = "", $mail_reply = "", $title_reply = "") { //if($_SERVER['SERVER_NAME'] == "localhost") return true; if (file_exists("../classes/mailer/class.phpmailer.php")) { require_once "../classes/mailer/class.phpmailer.php"; } $content = eregi_replace("[\\]", '', $content); $title_from_name = translate("Thông báo từ hott.vn"); $mail = new PHPMailer(); $arrayHost = array(1 => "mta8.mailmytour.com", 2 => "mta6.mailmytour.com"); $host = array_rand($arrayHost); $mail->IsSMTP(); $mail->SMTPAuth = true; // enable SMTP authentication //$mail->SMTPSecure = "ssl"; // sets the prefix to the servier $mail->Host = $arrayHost[$host]; // SMTP server $mail->Port = 25; // set the SMTP port for the GMAIL server $mail->From = "*****@*****.**"; $mail->FromName = $title_from_name; $mail->Username = "******"; // GMAIL username $mail->Password = "******"; // GMAIL password $mail->CharSet = "UTF-8"; $mail->ContentType = "text/html"; $mail->Subject = $title; $mail->AddAddress($to); $mail->Body = $content; //HTML Body if ($attach_file != "") { $mail->AddAttachment($attach_file); } $mail->IsHTML(true); // send as HTML $mail->SMTPDebug = 1; //$mail->SMTPDebug = true; //Print bug info when sent $send = $mail->Send(); $arrayError = array(); $arrayError["Host"] = $mail->Host; $arrayError["From"] = $mail->FromName; $arrayError["Email"] = $to; $arrayError["subject"] = $mail->Subject; $arrayError["Error"] = $mail->ErrorInfo; saveLog1("all_email", json_encode($arrayError)); if (!$send) { //Nếu không send được thì thử lại với account khác, chỉ thử lại max đến 2 lần là dừng lại //strlen($id_error) <= 3 - Ứng với 1 lần retry if (strlen($id_error) <= 3) { ///send_mailer($to, $title, $content, $id_error); } /* echo "Email chua duoc gui di! <p>"; echo "Loi: " . $mail->ErrorInfo; */ //exit; saveLog1("error_email", "Loi: " . $mail->ErrorInfo); return false; } else { //trường hợp mail gửi thành công //echo $user_name . "<br>"; //echo "Email da duoc gui!"; return true; } }