Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9165621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:56:57+00:00 2026-06-17T14:56:57+00:00

I’m having a little issue running a cron job. I’ve created this script to

  • 0

I’m having a little issue running a cron job. I’ve created this script to help me automatically send out an email bulletin IF the date in the database matches todays date, ELSE it will send an email to administrators in order to inform them that there was no bulletin sent. I’ve checked to see that all of the emails existed, as well as the email group inbox, and there were no emails received. The script written in below, followed by the email error I get when the cron job runs. Thanks in advance!

//Set variable which contains the query to the database
$userbcc = $connection->prepare("SELECT email FROM users ORDER BY email ASC") or die("could not connect");

//Execute the query through MySQLi
$userbcc->execute();

//Stores the number for counting
$userbcc->store_result();

//Bind results to their variables
$userbcc->bind_result($email);

//While results 
while ($userbcc->fetch()) {
    $userlist .= $email . ",";
}

//Count the rows
$user_rows = $userbcc->num_rows;

$userbcc->close();


//Set and sanitize the variable which contains perameter
$today = date("Y-m-d 00:00:00");

//Set variable which contains the query to the database
$mailpromo = $connection->prepare("SELECT id,venid,title,intro,body,sdate,edate FROM venpromo WHERE `sdate` =  ?") or die("could not connect");

//Set the query 'WHERE state = ?' to the query
$mailpromo->bind_param("s",$today);

//Execute the query through MySQLi
$mailpromo->execute();

$mailpromo->store_result();

//Bind results to their variables
$mailpromo->bind_result($id,$venid,$title,$intro,$body,$sdate,$edate);

$ad_rows = $mailpromo->num_rows;

//While results 
while ($mailpromo->fetch()) {
    $to = "[EMAIL ADDRESS]";
    $from = "[EMAIL ADDRESS]";
    $subject = "A New Promo Starts Today! \"$title\"";
    $message = "MESSAGE";
        $headers = "From: Norris Portal Intranet System <[EMAIL ADDRESS]>\r\n";
    $headers .= "Reply-To: ". strip_tags($from) . "\r\n";
    $headers .= "BCC: " . substr($userlist, 0, -1) . "\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
    if ($from != "" && $to != "" && $subject != "" && $message != "") {
        if (mail($to, $subject, $message, $headers)) {
            $mailsuccess = 1;
        } else {
            $mailfail = "1";
        }
    } else {
        $mailfail = "1";
    }
}

$mailpromo->close();


if ($ad_rows == 0) {
    $to = "[EMAIL ADDRESS]";
    $from = "[EMAIL ADDRESS]";
    $subject = "There were no promo's pulled from today's bulletin.";
    $message = "There were no promo's emailed to the staff today. Only promo's with a start day of today will be emailed to the staff.";
    $headers = "From: Norris Portal Intranet System <[EMAIL ADDRESS]>\r\n";
    $headers .= "Reply-To: ". strip_tags($from) . "\r\n";
    $headers .= "BCC: [EMAIL ADDRESS]\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
    if ($from != "" && $to != "" && $subject != "" && $message != "") { 
        if (mail($to, $subject, $message, $headers)) { 
            $mailsuccess = 1;
        } else {
            $mailfail = "1";
        }
    } else {
        $mailfail = "1";
    }
}

?>

ERROR EMAIL:

220-host238.hostmonster.com ESMTP Exim 4.80 #2 Mon, 21 Jan 2013 13:10:02 -0700 
220-We do not authorize the use of this system to transport unsolicited, 
220 and/or bulk e-mail.
250-host238.hostmonster.com Hello localhost.localdomain [127.0.0.1]
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
250-host238.hostmonster.com Hello localhost [127.0.0.1]
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
250 OK
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
250 Accepted
550 No Such User Here"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T14:56:58+00:00Added an answer on June 17, 2026 at 2:56 pm

    I rewrote my code and this worked… The solution was to pull the content first and use a while loop to email the content one-by-one instead of add all emails to a BCC: list…

    //Set variable which contains the query to the database
    $mailpromo = $connection->prepare("SELECT id,venid,title,intro,body,sdate,edate FROM venpromo WHERE `sdate` =  ?") or die("could not connect");
    
    //Set the query 'WHERE state = ?' to the query
    $mailpromo->bind_param("s",$today);
    
    //Execute the query through MySQLi
    $mailpromo->execute();
    
    //Stores the number for counting
    $mailpromo->store_result();
    
    //Bind results to their variables
    $mailpromo->bind_result($id,$venid,$title,$intro,$body,$sdate,$edate);
    
    //Bind results to their variables
    $mailpromo->fetch();
    
    //Count the number of bulletins today
    $mail_count = $mailpromo->num_rows;
    
    //Close the session
    $mailpromo->close();
    
    
    
    //Set variable which contains the query to the database
    $userbcc = $connection->prepare("SELECT email FROM users") or die("could not connect");
    
    //Execute the query through MySQLi
    $userbcc->execute();
    
    //Stores the number for counting
    $userbcc->store_result();
    
    //Bind results to their variables
    $userbcc->bind_result($email);
    
    //While results 
    while ($userbcc->fetch()) {
    
    
        $to = $email;
        $from = "[email held]";
        $subject = "A New Promo Starts Today! \"$title\"";
        $message = "[content held]"
    
        $headers = "From: [email held] \r\n";
        $headers .= "Reply-To: ". strip_tags($from) . "\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        if ($from != "" && $to != "" && $subject != "" && $message != "") {
            if (mail($to, $subject, $message, $headers)) {
                $mailsuccess = 1;
            } else {
                $mailfail = "1";
            }
        } else {
            $mailfail = "1";
        }
    
    
    
    
    }
    
    //Close the session
    $userbcc->close();
    
    
    if ($mail_count == 0) {
        $to = "[email held]";
        $from = "[email held]";
        $subject = "There were no promo's pulled from today's bulletin.";
        $message = "There were no promo's emailed to the staff today. Only promo's with a start day of today will be emailed to the staff.";
        $headers = "[email held]\r\n";
        $headers .= "Reply-To: ". strip_tags($from) . "\r\n";
        $headers .= "BCC: [email held]\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        if ($from != "" && $to != "" && $subject != "" && $message != "") { 
            if (mail($to, $subject, $message, $headers)) { 
                $mailsuccess = 1;
            } else {
                $mailfail = "1";
            }
        } else {
            $mailfail = "1";
        }
    }
    
    ?>
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.