[how to] make phplist work with Cron Jobs

Solutions for other advanced phplisters

Solution worked?

Still working on it
Total votes : 57

[how to] make phplist work with Cron Jobs

Postby Daniela » 10:01pm, Tue 18 Jan, 2005

I've seen a lot of people asking how to setup PHPlist to send e-mail automatically, especially when their databases are big (like mine 68,000) or their hosts does not allow them to send more than a couple of e-mails an hour. :idea:
I'll try to explain them as simple as possible.
I organized a couple of discussions, and I will like to thank karma and drubarth, they are definitely the best. :D
I hope this can get everybody working.
You can chek their original discussion at their links :

Our domain is going to be called "water" (I'm using common words so they don't get confusing during the explanation). http://www.water.com
Our PHPlist installation is going to be installed in the directory "fountain"
Username : "fish" and password : "seashell"

First of all, (like most mortals) you have to install PHPlist.
On our case,we go through Fantastico and install it.
Now we have to create a file called "phplist" (without the quotes please) in the same directory as the phplist installation.
The file should contain the follwing code


# script to run PHPlist from commandline. You may need to edit this to make it work
# with your shell environment. The following should work for Bash

# in commandline mode, access is restricted to users who are listed in the config file
# check README.commandline for more info

# identify the config file for your installation
export CONFIG

# alternatively you can use -c <path> on the commandline

# run the PHPlist index file with all parameters passed to this script
/usr/bin/php /home/water/public_html/fountain/admin/index.php $*

Copy and paste it as it is, but remember to replace the domain, directory, user, password, etc. Double check there are no spaces or enter after the last character.

One this is completed, now we have to edit a file named "config.php" which is located in /public_html/fountain/config/
Check that the following line looks like this :
And this line:
Now look for the following lines
# define the length of one batch processing period, in seconds (3600 is an hour)

and add the following line after it:
# Throttle sending messages; indicates the number of milliseconds to pause
# between each message (millisecond is one-millionth of a second)

This means is going to send an e-mail every 2 secconds.

Now look for the file "processqueue.php" in the directory /public_html/fountain/admin/
Find the following line:
output("Sending $messageid to $useremail");

and add the following just after it

Save the file.

We are almost done. Just hang on a little.
Now lets go to cron jobs.
You just have to sent this up once, the day and hour you want the queue to start to be processed.
The command should look like this
php /home/water/public_html/fountain/admin/index.php page=processqueue login=fish password=seashell

Now relax, prepare you message, queue it, and just watch it work.
By the way don't hit the process queue that you have on the phplist homepage, just forget about that link.

By the way, just let me know if it worked.
PL Nut
Posts: 16
Joined: 9:50pm, Tue 23 Nov, 2004


Postby magicmask » 6:41pm, Wed 26 Jan, 2005

Daniela, Thanks!

You supplied/summarized a fairly clear and understandable solution for the ever returning problem of batch mailing and server overloads.

Very useful!

phpList newbie
Posts: 1
Joined: 6:31pm, Wed 26 Jan, 2005

Coming closer to a solution

Postby RoelSmelt » 8:20pm, Tue 01 Feb, 2005

It seems that your solution will also work for my situation. I have a rss-feed and I would like to make this available per email for people who do not yet understand feedreaders.

I have followed your clear instructions. In the eventlog of PHPlist I can see that the processqeue was activated. I will try to make anothe Cron job with getrss.
If this works together, we have done a great job...
phpList newbie
Posts: 2
Joined: 2:40pm, Thu 09 Dec, 2004

Thanks You!!!

Postby cybersalt » 10:04pm, Thu 03 Feb, 2005


Your solution also worked for me. I have been hoping for months a solution to the cron dilemma would come along as for me I really need scheduled sending for my daily mailings.

Daniela, I can't thank you enough for your very easy to follow instructions to implement the solution. They were right at my level of understanding.

Posts: 11
Joined: 7:11am, Sun 14 Nov, 2004

Postby staticfiends » 7:45am, Sat 05 Feb, 2005

I tried to install your solution, but I get this error report sent to me:
Status: 404
Content-type: text/html
X-Powered-By: PHP/4.3.2

No input file specified.

any idea what I'm doing wrong?
Posts: 9
Joined: 7:11am, Sat 05 Feb, 2005

Postby abaykamau » 1:41am, Mon 14 Feb, 2005


Be certain to check the path to your file...it may not be "html" in some cases its "public_html" but whatever the path to your file, you will need to modify the cron accordingly.
PL Geek
Posts: 104
Joined: 3:09am, Mon 15 Nov, 2004
Location: Baltimore, MD

Postby staticfiends » 3:27am, Tue 15 Feb, 2005

abaykamau wrote:Static,

Be certain to check the path to your file...it may not be "html" in some cases its "public_html" but whatever the path to your file, you will need to modify the cron accordingly.

aha...thanks 8)

it is "pubic_html" but I have a different "water" than that of my domain name...so that must be where the error is coming from

thanks a bunch :D
Posts: 9
Joined: 7:11am, Sat 05 Feb, 2005

Postby staticfiends » 2:06pm, Tue 15 Feb, 2005

now it gives me this sent to me: :shock:

Code: Select all
Content-type: text/html
X-Powered-By: PHP/4.3.10
Set-Cookie: PHPSESSID=b5f14d33e1a5c188f1fed91fb37e5baf; 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

<!-- using ../config/config.php -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd">

<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
<meta http-equiv="pragma" content="no-cache">
<link rev="made" href="mailto:phplist%40tincan.co.uk">
<link rel="home" href="http://www.phplist.com" >
<link rel="copyright" href="mailto:phplist%40tincan.co.uk" >
<meta name="Author" content="Michiel Dethmers - http://www.phplist.com">
<meta name="Copyright" content="Michiel Dethmers, Tincan Ltd - http://tincan.co.uk">
<meta name="Powered-By" content="PHPlist version 2.8.12">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script language="javascript" type="text/javascript" src="js/select_style.js"></script><meta http-equiv="Cache-Control" content="no-cache, must-revalidate"><meta http-equiv="Pragma" content="no-cache"><title>PHPlist :: PHPlist :: Send message queue</title><link href="styles/phplist.css" type="text/css" rel="stylesheet">
<body bgcolor="#ffffff" background="images/bg.png">
<a name="top"></a>
<div align=center>
<table cellspacing=0 cellpadding=0 width=710 border=0>
<td bgcolor="#000000" rowspan=3><img height=1 alt="" src="images/transparent.png" width=1 border=0></td>
<td bgcolor="#000000"><img height=1 alt="" src="images/transparent.png" width=708 border=0></td>
<td bgcolor="#000000" rowspan=3><img height=1 alt="" src="images/transparent.png" width=1 border=0></td>

<tr valign="top" align="left">
<!--TOP TABLE starts-->
<TABLE cellSpacing=0 cellPadding=0 width=708 bgColor="#ffffff" border=0>
  <TR vAlign=top>
    <TD colSpan=2 rowspan="2" height="63" background="images/topstrip.png"><a href="http://www.phplist.com" target="_blank"><img src="images/masthead.png" border=0 width=577 height=75 alt=""></a></TD>
    <TD align=left
      background="images/topstrip.png" bgcolor="#F0D1A3"><FONT
      size=-2>&nbsp;<I>powered by: </I><BR>&nbsp;<B>[<a class=powered
      href="http://www.php.net/" target=_new><I>PHP</I></a>]</B> + <B>[<a
      class=powered href="http://www.mysql.com/"
  <TR vAlign=bottom>
    <TD vAlign=bottom width=132
    background="images/topright.png" bgcolor="#F0D1A3"><SPAN
    <TD bgColor="#000000"><IMG height=1 alt=""
      src="images/transparent.png" width=20
    <TD bgColor="#000000"><IMG height=1 alt=""
      src="images/transparent.png" width=576
    <TD bgColor="#000000"><IMG height=1 alt=""
      src="images/transparent.png" width=132
  <TR vAlign=top>
<td><div align=left>
<br />
<p class="leaftitle">PHPlist - send message queue</p><div><font style="font-size : 12px;font-family : Arial, Helvetica, sans-serif;        font-weight : bold;"> good afternoon ause</font></div><div align="right"><a href="./?page=logout&PHPSESSID=b5f14d33e1a5c188f1fed91fb37e5baf">logout</a></div><script language="javascript" type="text/javascript">
onerror = null;
this.onerror = null;
<script language="Javascript" src="js/progressbar.js" type="text/javascript"></script><form method=post name="outputform"><textarea name="output" rows=22 cols=75></textarea></form>
Posts: 9
Joined: 7:11am, Sat 05 Feb, 2005

Postby SWI » 11:48pm, Wed 16 Feb, 2005

good instructions. But still not working for me. what is weird is i can put the command in and it will run. but once I put it in a cron job it doesnt run. I do have cron capabilities

this is my cron job anything wrong with it?
Code: Select all
45 * * * * * php /home/u5/mydir/html/phplist/public_html/lists/admin/index.php page=processqueue login=username password=password

it works at the shell just like that but doesnt for the cron job
PL Geek
Posts: 73
Joined: 5:09am, Wed 04 Aug, 2004

Postby jre » 2:45pm, Thu 17 Feb, 2005

Just a couple of random thoughts...
Where does cron start from, what environment variables does it have, and what user context does it run under? In other words, do you need to put the path before the 'php' command, or do you need to give the cron-user rights to either php or to the phplist directories/files?

PL Nut
Posts: 23
Joined: 2:41pm, Fri 11 Jun, 2004

Work !!!

Postby virtualia » 7:59am, Fri 18 Feb, 2005

thanks a lot Daniela, your solution work for my 17000 list's.
I set the throttle to one half a second (500000) and work well!
Thanks to phplist staff too for that useful tool.

phpList newbie
Posts: 1
Joined: 7:47am, Fri 18 Feb, 2005

Postby mnc » 12:54am, Mon 21 Feb, 2005

I seem to suffer from this issue as well...

I have 3198 users set to drop 200 every 2mins...

ideally you are suppose to receive a confirmation for each batch sent correct... it seems that only the first 200 has gone out as that was the only confirmation I received

I will try the above suggest method and let you know if it works for me else I will have to drop the software for DaDa since I just don't have the time to tinker with it to make it work...
Posts: 6
Joined: 9:37am, Wed 26 Jan, 2005

Postby j0ram » 8:50pm, Sat 26 Feb, 2005

I did all that, and come up with...
Error: Sorry, You (j0ram) do not have sufficient permissions to run this script

This sounds like it's coming from php itself, and not phplist?
Posts: 6
Joined: 1:43pm, Thu 17 Jun, 2004

throttle email

Postby mrdg » 8:28am, Tue 01 Mar, 2005


Thanks for this hack, i have entered everything as described, but i dont want to send out a test as the people in my 500+ list as they only receive a mail once a month.

Is there anyway i can test this without sending out mails?

Do you ever thing phplist will add this to there product.

thanks again for the info
PL Nut
Posts: 18
Joined: 2:58pm, Mon 28 Feb, 2005

it worked

Postby mrdg » 8:16am, Wed 02 Mar, 2005

Thanks to everyone who put this thread together.

I sent a message to 10 emails and it took 39 seconds which is great..
I was suspended for sending 581 emails in 400 seconds.
It worked....

PL Nut
Posts: 18
Joined: 2:58pm, Mon 28 Feb, 2005


Return to Advanced Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 1 guest