Jump to content


Member Since 20 May 2008
Offline Last Active Oct 16 2015 04:29 AM

Posts I've Made

In Topic: cronjob wont send

15 October 2015 - 08:36 AM

After setting my email to get the cron response, this is the error i got from the cron with my html messages:


Status: 302 Moved Temporarily
X-Powered-By: PHP/5.4.43
Set-Cookie: PHPSESSID=9aa0e1459caeb93365729438b3b12f54; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-type: text/html

In Topic: cronjob wont send

10 October 2015 - 09:13 PM

You can log output like so:

/usr/local/bin/php -q /home/username/directory/directory/file-name.php >> /log/file/path.log
Make the path something that the CRON owner has write permissions to. Make sure that error reporting is turned on in the script.


the cron owner has write permissions. was wondering maybe cron does not understand/cannot read sub-directory structure?

In Topic: cronjob wont send

08 October 2015 - 01:44 PM

What does the script do? Are there any errors logged? Is cron set up to email you the results?


The script is suppose to send a reminder to members. I don't think there's any error logged cos i didn't get any. Yes the cron is set up to send a mail to me but i got no mail as well.


In Topic: sending mails to different users with different values from database

30 September 2015 - 03:45 AM


Really all you have to do is put the mail sending logic into the loop rather than after it. Right now, you just keep overwriting the same set of variables in your loop, and then you send a single mail with the data that happens to come last.


However, you still need to fix some things:

  • You should send the e-mails in a controlled manner with an upper limit per script execution (e. g. at most 100 mails). Clearing your entire database table at once is not a good idea, because it may overload your server or even be abused for DoS attacks.
  • Never insert raw strings into an HTML context. This applies to both websites and e-mails. While most e-mail clients won't execute any injected scripts, this is still very unprofessional and may be flagged as malicious content. Use HTML-escaping with htmlspecialchars().



Thanks. I modified the code but

i know sending all the mails at once will curse flooding, was thinking i'd find a way around that later but thanks for reminding. but how will the script know the first hundred mails it has sent? or does it mean i will have to create another table so that after sending a 100 it marks them as sent/1 as the case maybe it updates the table column and loop again for those not sent.

In Topic: sending mails to different users with different values from database

30 September 2015 - 03:43 AM

your loop should only be retrieving the data, forming the $message body with the data values, clearing any previous To: address (see the ClearAddresses() method), set the To: address from the data, and call the send() method. all the rest of the phpmailer related logic should exist only once and come before the start of your loop.


you would also want to check if the send() method indicated success or failure. if it failed, log the error information and the user's email address. if it was successful, you would probably want to set a status value somewhere to indicate that the email was sent (though this is no guarantee that it was received) so that you don't repeatedly send the same reminder email.


Thanks. I have just modified the code. But I'm not sure if i got the ClearAddresses() method usage correctly.