-
StackOverflow 文件
-
PHP 教程
-
傳送電子郵件
-
使用 PHPMailer 傳送 HTML 電子郵件
<?php
$mail = new PHPMailer();
$mail->From = "from@example.com";
$mail->FromName = "Full Name";
$mail->addReplyTo("reply@example.com", "Reply Address");
$mail->addAddress("recepient1@example.com", "Recepient Name");
$mail->addAddress("recepient2@example.com");
$mail->addCC("cc@example.com");
$mail->addBCC("bcc@example.com");
$mail->Subject = "Subject Text";
$mail->isHTML(true);
$mail->Body = "<html><body><p><b>This paragraph is bold.</b></p><p><i>This text is italic.</i></p></body></html>";
$mail->AltBody = "This paragraph is not bold.\n\nThis text is not italic.";
if($mail->send()) {
// Success! Redirect to a thank you page. Use the
// POST/REDIRECT/GET pattern to prevent form resubmissions
// when a user refreshes the page.
header('Location: http://example.com/path/to/thank-you.php', true, 303);
exit;
}
else {
echo "Error: " . $mail->ErrorInfo;
}