-1

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..

Girish
  • 11
  • 2
  • And "mail sending is not working" means what _exactly_? – arkascha Jun 15 '17 at 10:30
  • Do you get an error message? Do you see anything in the http servers error log file? Do you get an message in a SPAM folder? Does the message return? – arkascha Jun 15 '17 at 10:30

1 Answers1

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);
Reena Mori
  • 647
  • 6
  • 15
  • Code dumps do not make for good answers. You should explain *how* and *why* this solves their problem. I recommend reading, "[How do I write a good answer?"](http://stackoverflow.com/help/how-to-answer) – John Conde Jun 15 '17 at 11:06
  • This is a common question and should be closed as a duplicate. It should not be answered. In the future please flag a as duplicate only. – John Conde Jun 15 '17 at 11:07
  • Also, please do not abuse the formatting tools. – John Conde Jun 15 '17 at 11:07