PHP:
參考:
<?php
// 建立 PHPMailer 物件及設定 SMTP 登入資訊
require("../phpMailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = "remote.smtp.server"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "me@localhost"; // SMTP username
$mail->Password = "123456"; // SMTP password
$mail->From = "myemail@localhost";
$mail->FromName = "My Name";
// 執行 $mail->AddAddress() 加入收件者,可以多個收件者
$mail->AddAddress("to@email.com","Josh Adams");
$mail->AddAddress("to2@email.com"); // optional name
$mail->AddReplyTo("jyu@aemtechnology.com","AEM");
$mail->WordWrap = 50; // set word wrap
// 執行 $mail->AddAttachment() 加入附件,可以多個附件
$mail->AddAttachment("path_to/file"); // attachment
$mail->AddAttachment("path_to_file2", "INF");
// 電郵內容,以下為發送 HTML 格式的郵件
$mail->IsHTML(true); // send as HTML
$mail->Subject = "testing email";
$mail->Body = "This is the <b>HTML body</b>";
$mail->AltBody = "This is the text-only body";
if(!$mail->Send())
{
echo "Message was not sent <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
// 建立 PHPMailer 物件及設定 SMTP 登入資訊
require("../phpMailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = "remote.smtp.server"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "me@localhost"; // SMTP username
$mail->Password = "123456"; // SMTP password
$mail->From = "myemail@localhost";
$mail->FromName = "My Name";
// 執行 $mail->AddAddress() 加入收件者,可以多個收件者
$mail->AddAddress("to@email.com","Josh Adams");
$mail->AddAddress("to2@email.com"); // optional name
$mail->AddReplyTo("jyu@aemtechnology.com","AEM");
$mail->WordWrap = 50; // set word wrap
// 執行 $mail->AddAttachment() 加入附件,可以多個附件
$mail->AddAttachment("path_to/file"); // attachment
$mail->AddAttachment("path_to_file2", "INF");
// 電郵內容,以下為發送 HTML 格式的郵件
$mail->IsHTML(true); // send as HTML
$mail->Subject = "testing email";
$mail->Body = "This is the <b>HTML body</b>";
$mail->AltBody = "This is the text-only body";
if(!$mail->Send())
{
echo "Message was not sent <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
http://yoonow.pixnet.net/blog/post/11618092-%E8%BD%89%E8%BC%89%EF%BC%9Aphp-%E9%80%8F%E9%81%8E-smtp-%E7%99%BC%E9%80%81%E9%83%B5%E4%BB%B6%E4%BD%BF%E7%94%A8phpmailer
沒有留言:
張貼留言