工作小筆記 年紀大了,常常會忘記….

23六月/10關閉

PHPMailer() SMTP寄信

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = "utf-8";
$mail->Host = "1.2.3.4";
$mail->SetFrom("from@abc.com", "寄件人");
$mail->AddReplyTo("from@abc.com","寄件人");
$mail->AddAddress("sendto@abc.com","收件人");

$mail->Subject = "主旨";
$mail->MsgHTML("內文");
$mail->AddAttachment("附加檔案","另外給檔案名稱");

if (!$mail->Send()) {
    echo "郵件寄送失敗: " . $mail->ErrorInfo;
}
分類於: PHP 沒有回覆