PHPList and Dreamhost

posted in: Software 0

Intro

I have been testing PHPList on Dreamhost. Yes Dreamhost offers an Announcement list, but I needed something with a nicer interface and PHPList seems to be the product of choice. After getting it to run, I needed a place to document how I put it together.PHPList installs without a problem and the manual processes all work fine, including the mail2list plugin. But setting up a cron job to process posting automatically has proven to be a Herculean task, especially as I am limited on my knowledge of cron.

So to document my process and maybe help out others, here is what is accomplished so far. There are 2 sections: the PHPList automated queue processing and the automated mail2list cron job.

System Configuration
standard dreamhost account
PHP5.3
PHPList 2.10.14

Of course you will need to adjust the scripts for your domain and userid. To allow command line processing, edit the phplist config file and update the $commandline_users to include the userid you have declared in the “export USER” statement in the cron_phplist.sh file.

**Security Note: I did not move the scripts above the website…wanted to keep things simple here, but you should consider putting your scripts where they are not accessible by the inquisitive user.

If these scripts look familiar, I found them on the web and adjusted them for Dreamhost. Unfortunately, I did not keep the reference to the original post….my bad.

PHPList Que Processing by Cron

The first step is to set up a script to be called by cron and then to actually setup the cron job.

The following script runs the php process from the command line. In this example the script is named cron_phplist.sh.

#!/bin/bash
#!/usr/local/php5/bin/php -q

# 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
CONFIG=/home/*domain*/admin/config/config.php
export CONFIG
export USER="*******"

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

# run the PHPlist index file with all parameters passed
# to this script

/usr/local/php5/bin/php /home/*user*/*domain*/*path-2-list*/
admin/index.php $*

Then on the Dreamhost control panel in the Goodies tab, set up the cron job with the following in the command line box as the command to run

/home/*user*/*domain*/admin/cron_phplist.sh -p processqueue

Set the frequency of of the run and your are set. Now any announcement that is posted will be automatically submitted and will not require the user to log in and keep their browser open for the duration of the send.

Mail2List Setup

Following the same technique as for processing the que, Create the following script which runs the call the php cron script that accepts messages from an email account. In this example the script is named cron_mail2.sh.

#!/bin/bash
#!/usr/local/php5/bin/php -q

# 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
CONFIG=/home/*user*/*domain*/admin/config/config.php
export CONFIG
export USER="*********"

# alternatively you can use -c <path> on the command line
# run the Mail2ist cron job with all parameters passed
# to this script
/usr/local/php5/bin/php /home/*user*/*domain*/m2l_cron.php $*

Then on the Dreamhost control panel in the Goodies tab, set up the cron job with the following in the command line box as the command to run

/home/*user*/*domain*/admin/*path-2-list*/
cron_mail2.sh -p processqueue

The cron job will run and accept emails from the email account and put them in the process que. The next time the process que is invoked, the announcement will be sent.

Comments are closed.