[Mailman-Users] Syntax question using the Web Interface with PHP

Mark Sapiro mark at msapiro.net
Tue May 17 12:32:14 EDT 2016


On 05/16/2016 12:55 PM, Terence Ronalds via Mailman-Users wrote:
> I'm trying to use the Web Interface from a PHP page and I have a problem when trying to add a person to a list. I can get it to work fine if I just add an email address to the list, however I can't figure out the syntax needed to also include their real name. Here's what I have that works so far:
> <?php
> $name='Adam B. Tester';
> $email=adam at somewhere.com';
> $sub_url = "http://lists.XXXX.com/admin.cgi/members-XXXX.com/members/add?subscribe_or_invite=0&send_welcome_msg_to_this_batch=0&notification_to_list_owner=0&adminpw=XXXX&subscribees_upload=";
> $content=file_get_contents($sub_url . $email );
> echo $content;?>


There are a few issues in the above. Some, like the missing ' in
$email=adam at somewhere.com'; and members-XXXX.com instead of
members_XXXX.com in the cPanel list name, I will assume are just typos
introduced when you tried to make a redacted version of a working
script, but for the rest, I don't know what you tried, so I don't know
why it didn't work, but I would use 'subscribees' rather than
'subscribees_upload'[1], and the syntax you need for the name/address is
described at <https://wiki.list.org/x/4030562>.

Also since your real name has a period in it, it needs to be quoted as

$name='"Adam B. Tester"';

Then you can do something like

$content=file_get_contents($sub_url . "$name <" . $email . ">");

I didn't actually try this, so you may find you need to do something like

$content=file_get_contents($sub_url . urlencode("$name <" . $email . ">"));

[1] I didn't write the FAQ at <https://wiki.list.org/x/4030567>, but I
have just edited it to change subscribees_upload to subscribees and to
add a pointer to <https://wiki.list.org/x/4030562>.

-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan


More information about the Mailman-Users mailing list