php简单实现一个邮件发送功能
//pear install Mail Mail_Mime //需要安装mail库
//mail("xxxxxxxxx@qq.com", "This is subject", "this is body");
require('Mail.php');
require('Mail/mime.php');
$name = "haha";
$recipient = "xxxxxxxxxx@qq.com";
$from = "";
$cc = "";
$subject = "this is subject";
//$body = "this is body";
$body = <<
this is body
reveaerveavr
html;
$headers['From'] = $from;
$headers['Cc'] = $cc;
$headers['Subject'] = $subject;
$mimemail = new Mail_mime();
$mimemail->setTxtBody($body);
//$mimemail->addAttachment('inventory.pdf', 'application/pdf'); //添加附件
$message = $mimemail->get();
$mailheaders = $mimemail->headers($headers);
$email = Mail::factory('mail');
$email->send($recipient, $mailheaders, $message) or die("can't send message");
?>