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" <[email protected]>

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 <[email protected]>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan
------------------------------------------------------
Mailman-Users mailing list [email protected]
https://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: 
https://mail.python.org/mailman/options/mailman-users/archive%40jab.org

Reply via email to