我正在为Php
mailer cron 工作编写代码。电子邮件正在发送和接收,但为什么我HTML
在电子邮件中收到代码。而不是HTML
模板。
我还使用了正确的电子邮件标题,并测试了其他用户的电子邮件帐户。HTML
但在电子邮件中打印代码也有同样的问题。
我也在<html><body><h2>Hello</h2></body></html>
消息中使用而不是模板代码。<html><body><h2>Hello</h2></body></html>
但在电子邮件接收中打印同样的问题。
php代码
//database connection
require_once("include/config.inc.php");
require_once("include/functions.inc.php");
//init function
mailerCrone();
//defined functions
function mailerCrone() {
$site_admin = 'myemail@gmail.com';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers = "From: " . $site_admin . "\r\n";
$headers .= "Reply-To: ". $site_admin . "\r\n";
$currentdate = date('Y-m-d H:i:s');
//get data to send mails
$getDataTomail = mysql_query("SELECT * FROM sendmails where status = 0 ORDER BY id ASC limit 0,10");
while($resDataTomail = mysql_fetch_array($getDataTomail)) {
$templateId = $resDataTomail['templ_id'];
$dataPreparedId = $resDataTomail['id'];
//get the template data
$getTemplate = mysql_query("SELECT * FROM templates where id = $templateId");
$resTemplate = mysql_fetch_array($getTemplate);
echo $msg = '<html><body>'.$resTemplate['templ_content'].'</body></html>';
//mail($to, $subject, $message, $headers);
$mailResponce = mail($resDataTomail['subs_email'], $resTemplate['templ_name'], $msg, $headers);
if($mailResponce == '1') {
//update status of selected data after send mail
$updateSendMailData = mysql_query("UPDATE sendmails SET status = '1' WHERE id = $dataPreparedId") or die(mysql_error());
}
}
}