Blog News

St.Ego's Blog + CMS Blog
Browse in : All > Topics > St.Ego's Blog
All > Topics > CMS Blog
Any of these categories - All of these categories

Getting at Mailman with PHP and Xaraya

Posted by: St.Ego on June 24, 2009 4:20:00 PM (757 Reads)

For some time now, I have been picking away at the idea of connecting the Mailman mailing list server to Xaraya. If I could get Xaraya to read Mailman data, including the list of members and the archive of posts, I could provide a powerful (and free) listserv to Xaraya members by automatically adding them to a mailing list in Mailman that is associated with membership in a specific group in Xaraya (ostensibly the default Users group, but any group could ostensibly be used for various purposes). Furthermore, I could automatically establish user accounts in Xaraya for all listserv members in Mailman, run via CRON to keep a Xaraya group and a Mailman list in sync together.

However, it's been an uphill battle getting at Mailman from anything but the command line... until now!

With the extensive help of my favorite UNIX server admin, Sean Carolan, I've had the opportunity to try just about every method of reaching Mailman that I know of.

The first trick, since I am working with Xaraya, was to get the Scheduler module set up so that CRON could access it successfully to begin with. In this case, we went with the External IP Address option in the Scheduler module and entered the IP address of the server. I will spare you all of the sordid details concerning ways that didn't work out...

To provide a location for the Mailman code, I created a new module to house it in for installation on Xaraya. I prefer to keep my applications modularized so that they are more easily distributed for consumption. I created a test function in the new modules xarschedulerapi sub-folder and created a call to it in the Scheduler module so that it would be fired when the Scheduler was initiated by CRON.

To do this yourself, just make an entry in your CRON tab that preceeds your Scheduler URL with wget. Use the full URL; I had issues trying to run it relative to local without the domain name.

Into this function I inserted some shell_exec commands to the Mailman functions, directly. I hid the results inside of an output buffer and had them emailed to me:

Well, I got the email, alright. Unfortunately, there was nothing in it. The server didn't like the Apache user trying to run those commands.

I could run the Mailman commands directly, via CRON, and get the results, but not when CRON was being used to run a Xaraya page on the website, even though it ran the Scheduler itself successfully.

So, I went through the whole thing with Sean, more than once, over the past few weeks (months?) to get this far but we just couldn't seem to get any further than the above.

Today, Sean finally found the problem when he got a permission denied error trying to run the Mailman commands from his own local user account. The file that caused the error, config.pck (located in the folder for each specific list), was subsequently CHMOD'ed to 777 to ensure it could be accessed.

Suddenly, the CRON job that ran the Scheduler began emailing me the members list from Mailman. With this in place, I can now proceed with the Mailman integration. I will be making it available in the Xaraya monotone repository once I have a few integration points worked out, but the above should be enough to get anyone else started with connecting to Mailman using PHP.

Good luck and happy coding!

Keywords : mailman scheduler xaraya

There are no comments attached to this item. You must be registered and logged in to post comments!

Options:
View Article Map
View Archives