经常会有定期发送邮件报表的需求,这里使用HTML写报表模板,然后填充数据后发送。
代码如下
1 2 3 4 5 6 7 8 9 10 11
| $content = str_replace($find, $replace, $htmlTemplate);
$to = 'xxx@baidu.com'; $subject = '数据日报-' . $day; $header = "MIME-Version: 1.0\r\n"; $header .= "Content-type: text/html; charset=utf-8\r\n"; $header .= "Content-Transfer-Encoding: 8bit\r\n"; $header .= "From: xx <xx@baidu.com>\r\n"; $header .= "Cc: xx@mailexample.com\r\n"; mail($to, $subject, $content, $header);
|