// 输出生成HTML可发送的邮件主体内容
function getMessage($result) {
$message = "
报表
产品 |
二级产品 |
xxx |
xx |
xxx |
xxx |
xxx |
";
$tr = "";
foreach($result as $k => $v) {
$tr .= "";
$tr .= "";
$tr .= $v["firstProduct"];
$tr .= $v["secondProduct"];
$tr .= $v["xxx"];
$tr .= $v["xxx"];
$tr .= $v["xx];
$tr .= $v["xxx"];
$tr .= $v["xxx"];
$tr .= " | ";
$tr .= "
";
}
$message .= $tr . "
";
return $message;
}
//程序主函数
function main() {
global $xxx_link;
$allUser = "
select
distinct x
from
a
";
$data = getAll($allUser,$xxx_link);
foreach($data as $k => $v) {
$userId = $v["user_id"];
$currentUser = "
SELECT
xxx
FROM
xxxx
";
$result = getAll($currentUser,$xxx_link);
$currentUserTemplate = getMessage($result);
$to = "xxxo@126.com";
$subject = "中文标题";
$subject = "=?UTF-8?B?".base64_encode($subject)."?=";
$headers = "MIME-Version: 1.0" . "\\r\\n";
$headers .= "Content-type:text/html;charset=utf-8" . "\\r\\n";
// 更多报头
$headers .= 'From:
' . "\\r\\n"; //邮件来源
// $headers .= 'Cc: xxx@xxxx.com' . "\\r\\n";
mail($to,$subject,$message,$headers);
}
}
// 这样就可以发送包含HTML格式的邮件体了。
利用的是sendmail发送。
阅读(4565) | 评论(0) | 转发(0) |