<a href=
'http://phpmailer.sourceforge.net/'>phpMailer</a>是個不錯的外掛,使用也算簡單,只要你會基本的OOP。
不過請記得class.phpmailer.php中$CharSet要改成big5或utf8,不然寄出的mail會是西歐語系的!以下是使用範例
----
require("../phpMailer/class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP
$mail->Host = "atl.mail.cbeyond.com"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "jyu@aemtechnology.com"; // SMTP username
$mail->Password = "12345"; // SMTP password $mail->From = "jimiyu@gmail.com";
$mail->FromName = "呆呆吉米魚@Gmail";
$mail->AddAddress("jimiyu@seed.net.tw","吉米魚@SeedNet");
$mail->AddAddress("jimiyu@gmail.com"); // optional name
$mail->AddReplyTo("jyu@aemtechnology.com","AEM"); $mail->WordWrap = 50; // set word wrap
$mail->AddAttachment("d:/index.php"); // attachment
$mail->AddAttachment("d:/AUTORUN.INF", "INF");
$mail->IsHTML(true); // send as HTML $mail->Subject = "測試mail";
$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";

TAG: php smtp 邮件 phpmailer mail 附件
