3

I have a website on the web, and I want to use CronJob, to send newsletters every Monday. Now, I'm using PHP to do this, and I'm stuck. I have a mail() function, that sends mail, to every address stated in a file.

Here is my CronJob file. I changed the date to everyday, just for debugging.

0 9 * * *   php -f /home/a4770799/public_html/mail/newsletter.php

Here is my PHP file. This is the whole file.

<?php
  $subject = "Weekly Newsletter";
  $msg = "This is a weekly newsletter debugging test.";
  $headers = "From: noreply@test.com" . "\r\n" .
             "Reply-To: example@test.com" . "\r\n";
  $linesofmail = file("mail_address_list.txt");
  foreach ($linesofmail as $line_num => $line) {
    mail ($line, $subject, $msg, $headers);
  }
?>

What might be the problem here? I would love it, if someone would explain the problem to me, instead of just giving me a piece of code.

FoxInFlame
  • 720
  • 10
  • 20

1 Answers1

3

You can check out the error log. It can be problem reading the mail_address_list.txt or php mail error.

Check this out to prevent mails moving to junk.

Nisha
  • 685
  • 1
  • 4
  • 16