I have written cron job in core php, mail sending code is also there.. due to cron tables updating properly but mail sending is not working..
my code:
<?php
..............
..............
$subject = "Thank you";
$message = '<table border="0" cellpadding="0" cellspacing="0" width="600" style="font-family: Tahoma, Geneva, sans-serif;font-size: 13px;width:600px; margin:20px auto;"><tr bgcolor="#00ADEF"><td align="center" valign="top" width="100%" style="font-family: Tahoma, Geneva, sans-serif;font-size: 13px;"><table border="0" cellpadding="10" cellspacing="0" width="100%" style="font-family: Tahoma, Geneva, sans-serif;font-size: 13px;"><tr align="center"><td><img src="path/cronjobs/cron_mail_img/mailTempLogo.png" width="198" style="max-width:198px; margin-top: 30px; margin-bottom: 30px;" /></td></tr></table></td></tr><tr bgcolor="#f5f5f5"><td align="center" valign="top" width="100%" class="templateColumnContainer"><table border="0" cellpadding="10" cellspacing="0" width="100%" style="font-family: Tahoma, Geneva, sans-serif;font-size: 13px;"><tr><td class="templateColumnContainer" style="padding:0px 20px;"><p style="font-size:16px; margin-bottom:5px;"><strong>Hi '.$row['payer_fname'].', </strong></p><p style="font-size:16px; margin-bottom:5px;">Thank you for choosing.. !</p><p style="font-size:16px; margin-bottom:5px;">Hope you had a great time.</p><p style="font-size:16px; margin-bottom:5px;">Please share your experience with us by just rating the property where you were living.</p><p style="font-size:16px; margin-bottom:5px;">Please <a href="path/rating/rating.php?prp_id='.base64_encode($row['property_id']).'&usr_id='.base64_encode($row['user_id']).'">rate the property..!</a></p></td></tr><tr style="background-color: #f5f5f5;"><td style="padding:20px;"><p style="font-size:16px; margin:10px 0;">Thanks, </p><p style="font-size:16px; margin:10px 0;">Team XYZ </p></td></tr><tr align="center" style="background-color: #f5f5f5;"><td style="border-top:solid 1px #CCC"> <img src="path/cronjobs/cron_mail_img/ftr-logo.png" width="39" /></td></tr></table></td></tr></table>';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: Domain<admin@xyz.com>' . "\r\n";
mail($row['payer_email'], $subject, $message, $headers);
..............
..............
?>
please suggest something..
答案 0 :(得分:0)
check bellow code you can not pass to email
$to = "somebody@example.com";
$subject ="Thank you";
$message = '<table border="0" cellpadding="0" cellspacing="0" width="600" style="font-family: Tahoma, Geneva, sans-serif;font-size: 13px;width:600px; margin:20px auto;"><tr bgcolor="#00ADEF"><td align="center" valign="top" width="100%" style="font-family: Tahoma, Geneva, sans-serif;font-size: 13px;"><table border="0" cellpadding="10" cellspacing="0" width="100%" style="font-family: Tahoma, Geneva, sans-serif;font-size: 13px;"><tr align="center"><td><img src="path/cronjobs/cron_mail_img/mailTempLogo.png" width="198" style="max-width:198px; margin-top: 30px; margin-bottom: 30px;" /></td></tr></table></td></tr><tr bgcolor="#f5f5f5"><td align="center" valign="top" width="100%" class="templateColumnContainer"><table border="0" cellpadding="10" cellspacing="0" width="100%" style="font-family: Tahoma, Geneva, sans-serif;font-size: 13px;"><tr><td class="templateColumnContainer" style="padding:0px 20px;"><p style="font-size:16px; margin-bottom:5px;"><strong>Hi '.$row['payer_fname'].', </strong></p><p style="font-size:16px; margin-bottom:5px;">Thank you for choosing.. !</p><p style="font-size:16px; margin-bottom:5px;">Hope you had a great time.</p><p style="font-size:16px; margin-bottom:5px;">Please share your experience with us by just rating the property where you were living.</p><p style="font-size:16px; margin-bottom:5px;">Please <a href="path/rating/rating.php?prp_id='.base64_encode($row['property_id']).'&usr_id='.base64_encode($row['user_id']).'">rate the property..!</a></p></td></tr><tr style="background-color: #f5f5f5;"><td style="padding:20px;"><p style="font-size:16px; margin:10px 0;">Thanks, </p><p style="font-size:16px; margin:10px 0;">Team XYZ </p></td></tr><tr align="center" style="background-color: #f5f5f5;"><td style="border-top:solid 1px #CCC"> <img src="path/cronjobs/cron_mail_img/ftr-logo.png" width="39" /></td></tr></table></td></tr></table>';
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers optional/headers
$headers .= 'From: <webmaster@example.com>' . "\r\n";
$headers .= 'Cc: myboss@example.com' . "\r\n";
mail($to,$subject,$message,$headers);