Using cronjob to remove and add members to a mailing list
I want to be able to run a cronjob on my server that uses a php script to add new users and/or remove users from a mailing list. Not having any luck finding any simple examples. My thought is that the php script would get email addresses from a database (which I can do) and then feed them to a mailman command line to either add or remove a user.
The cronjob is entered via Cpanel. Have several cronjobs that modify databases but have never tried something that would actually execute a unix command.
Thanks, Pineyscripter
On 06/05/2015 09:04 AM, Jerry Barnabee wrote:
I want to be able to run a cronjob on my server that uses a php script to add new users and/or remove users from a mailing list. Not having any luck finding any simple examples. My thought is that the php script would get email addresses from a database (which I can do) and then feed them to a mailman command line to either add or remove a user.
Mailman's sync_members command does exactly what you want. You would use proc_open() in your php script to create pipes to and from the command, then write the desired membership list one user per line in the form
"User's Name" <user@example.com>
to the command's input and read the output. The display name in the above example is optional, but is used as the real_name attribute of a user added by the command.
The cronjob is entered via Cpanel. Have several cronjobs that modify databases but have never tried something that would actually execute a unix command.
In cPanel, the command you want is /usr/local/cpanel/3rdparty/mailman/bin/sync_members.
/usr/local/cpanel/3rdparty/mailman/bin/sync_members -h
will give usage info. The actual command you'd run with proc_open() is
/usr/local/cpanel/3rdparty/mailman/bin/sync_members -f - LISTNAME
where -f - says use stdin as the input and LISTNAME is the actual cPanel list_domain list name. See the help for other options controlling notices and whether or not to actually update the list or just report (good for testing).
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
Is there also a way that I can also set the moderation bit for the user to on or off
On 8/9/22 11:35, jerry.barnabee@gmail.com wrote:
Is there also a way that I can also set the moderation bit for the user to on or off
See the script at https://www.msapiro.net/scripts/set_mod.py
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
participants (3)
-
Jerry Barnabee
-
jerry.barnabee@gmail.com
-
Mark Sapiro