PHP 源码:PHP 实现邮件群发的源码
本文主要为大家分享了 PHP 下实现邮件群发的代码,欢迎参考,修改。
代码如下:
<?php
//
请求 PHPmailer
类 文件
require_once
("class.phpmailer.php");
//发送 Email
函数
function
smtp_mail (
$sendto_email
,
$subject
,
$body
,
$extra_hdrs
,
$user_name
) {
=
new
PHPMailer();
->IsSMTP();
// send via SMTP
->Host = "smtp.163.com";
// SMTP servers
->SMTPAuth = true;
// turn on SMTP authentication
->Username = "jessiejl";
// SMTP username
注意:普通邮件认证不需要加 @
域名
->Password = "1983106";
// SMTP password
->From = "";
//
发件人邮箱
->FromName = "WWW.NIUTW.COM";
//
发件人 ,
比如 唯美搭配网
->CharSet = "GB2312";
//
这里指定字符集!
->Encoding = "base64";
->AddAddress(
$sendto_email
,
$user_name
);
//
收件人邮箱和姓名
->AddReplyTo("","Web 之家");
//$mail->WordWrap = 50; // set word wrap
//$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment 附件 1
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); //附件 2
->IsHTML(true);
// send as HTML
->Subject =
$subject
;
//
邮件内容 可以直接发送 html
文件
->Body = <<<EOT
<html>
<head>