PHP / Cronjob mail function

I have a website on the Internet and I want to use CronJob to send newsletters every Monday. Now I am using PHP for this and I am stuck. I have a mail () function that sends mail to every address in the file.

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

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


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

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


What could be the problem? I would love it if someone could explain this problem to me and not just give me the code.


source to share

1 answer

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

Check this to prevent mail from being moved to spam.



All Articles