PHP Mailer

$mail = new PHPMailer();
mb_internal_encoding('UTF-8'); //避免主題亂碼

//Function
function MyMailer($mail, $to, $mailbody, $subject, $attachtrue, $filename) {

global $smtpsecure2, $smtphost2, $smtpport2;
global $username2, $password2, $replyto2;
global $from2, $fromname2;

$mail->IsSMTP();
$mail->SMTPAuth   = true;  // enable SMTP authentication
$mail->SMTPSecure = $smtpsecure2;
$mail->Host       = $smtphost2;
$mail->Port       = $smtpport2;
$mail->Username   = $username2;
$mail->Password   = $password2;
$mail->AddReplyTo($replyto2,$fromname2);
$mail->From       = $from2;
$mail->FromName   = $fromname2;
$mail->Subject    = mb_encode_mimeheader($subject, "UTF-8");
$mail->WordWrap   = 50; // set word wrap
$mail->MsgHTML($mailbody);
$mail->AddAddress($to, "");
//charset
$mail->CharSet="UTF-8";

if($attachtrue == 1) {

for($i = 0; $i < count($filename); $i++) {
$mail->AddAttachment("attach/".$filename[$i]);
}
}

$mail->IsHTML(true); // send as HTML

if(!$mail->Send()) {
echo '<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />';
echo "Error: " . $mail->ErrorInfo;
} else {
echo '<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />';
echo "Success!";
}

}

Leave a reply

required

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>