自动发送邮件:自动发送邮件实现方法

今天我们一起来看看自动发送邮件实现方法
参考:[http://www.crazycoder.cn/] 首先声明,看这篇文章的人要懂得php基本知识。

从http://sourceforge.net/project/showfiles.php?group_id=26031

下载到phpmailer,然后接压缩,把class.phpmailer.php,class.smtp.php拷贝到你的include目录下面,

下面是test.php测试发送邮件:

<?php
require(\"yourinlucepath/class.phpmailer.php\");

$mail = new PHPMailer();

$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = \"smtp1.example.com;smtp2.example.com\"; // 比如:smtp.163.com;mail.tsinghua.org.cn
$mail->SMTPAuth = true; // 认证功能
$mail->Username = \"jswan\"; // 用户名,比如guozijian
$mail->Password = \"secret\"; // 密码

$mail->From = \"[email protected]\"; //你发送的邮件的来自方,可以不填你自己的邮箱
$mail->FromName = \"Mailer\";
$mail->AddAddress(\"[email protected]\", \"Josh Adams\"); //要发送的人的邮箱
$mail->AddAddress(\"[email protected]\"); // name is optional
$mail->AddReplyTo(\"[email protected]\", \"Information\");//回复人

$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->AddAttachment(\"/tmp/image.jpg\", \"new.jpg\"); // 附件

$mail->IsHTML(true); // set email format to HTML

$mail->Subject = \"Here is the subject\";
$mail->Body = \"This is the HTML message body <b>in bold!</b>\";
$mail->AltBody = \"This is the body in plain text for non-HTML mail clients\";

if(!$mail->Send())
{
echo \"Message could not be sent. <p>\";
echo \"Mailer Error: \" . $mail->ErrorInfo;
exit;
}

echo \"Message has been sent\";
?>

//phpmailer类 (两个大类)

就这样就搞定了,是不是很简单呢?呵呵

Tags:  如何发送邮件 vb自动发送邮件 自动发送电子邮件 自动发送邮件

延伸阅读

最新评论

发表评论