charset = "UTF-8"; $this->host = "mail.masada.com.tw"; $this->port = 25; $this->smtp_user = "notice"; // 這裡填寫SMTP登入帳號, 例如 your.gmail.name@gmail.com 則填寫your.gmail.name $this->smtp_pwd = "90493119"; // 這裡填寫SMTP登入密碼 } function sendx($subject = "", $em_body = "", $sendlist = array(), $from = "永佳捷科技", $bcc = "", $files = array()) { if (!$sendlist) return; $em_body = nl2br($em_body); $em_body .= "
※此信件為系統發出信件,請勿直接回覆。
"; $mail = new PHPMailer(true); $mail->IsHTML(true); //設定是否使用HTML格式 $mail->CharSet = $this->charset; $mail->isSMTP(); $mail->SMTPAuth = true; $mail->Host = $this->host; $mail->Port = $this->port; $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //使用SSL, 如果是TLS 請改為 PHPMailer::ENCRYPTION_STARTTLS $mail->Username = $this->smtp_user; $mail->Password = $this->smtp_pwd; $mail->SMTPSecure = ""; $mail->From = "notice@masada.com.tw"; $mail->FromName = $from; $mail->Subject = $subject; $mail->Body = $em_body; foreach ($sendlist as $v) { // $sendlist[0]=['M0044', 'jrbin@masada.com.tw'] list($name, $email) = $v; if ($email) $mail->addAddress($email, $name); } //$mail->addCC("personC@gmail.com", "person C"); //$mail->addBCC("personD@gmail.com", "person D"); //$mail->addAttachment("image1.jpg", "picture.jpg"); //設定附件, 對方會看到附件名稱為 picture.jpg foreach ($files as $v) { list($file, $file_name) = $v; $mail->addAttachment($file, $file_name); } //print_r($mail);exit; if (!$mail->Send()) { // echo "Mailer error: " . $mail->ErrorInfo; } else { //echo "Email sent"; } } }