![](https://secure.gravatar.com/avatar/46d27433ede19aa8a6500569fa5e7711.jpg?s=120&d=mm&r=g)
Hello,
I have a signup sheet that subscribes people to a Mailman list by using PHP to call add_members (the PHP is below, FYI). My problem is that add_members seems to ignore the email confirmation settings from the admin interface. Even though my list is configured to send a confirmation message, subscribers only get the "Thanks for signing up!" email.
Does anyone know of a way to use add_members in a confirmed-opt-in list? Thanks very much!
-Ren
=-=-=-=-=-=-=-
<h2>Subscription Results</h2>
<?php
// The path to your add_members program here: $ADD_MEMBERS = '/your/path/to/add_members';
// The name of your mailing list: $LIST = 'FakeList';
// The email address from the form, run through a process // that removes nasty scripting attacks $adrs = escapeshellcmd($_GET['email']);
// Runs the pipeline and stores the output in an array exec("echo $adrs | $ADD_MEMBERS -r - $LIST", $output, $return_var);
// Implodes the array into a string $msg = implode('', $output);
// Search for 'Subscribed' in $msg. Then we know if it worked or not.
if (strpos($msg, 'Subscribed') === FALSE) { print "Crap! Something went wrong and you were not subscribed."; } else { print "It worked!"; }
?>
![](https://secure.gravatar.com/avatar/f07ab66e1cdf0b3862943bafe6b683b1.jpg?s=120&d=mm&r=g)
On Fri, 2005-10-21 at 14:23 -0400, Ren Bucholz wrote:
Not is its current manifestation. The reason is that manual adding of members assumes this is an approved action. You have two choices:
redirect them to the signup page for the list (this has the advantage of allowing the user to set some preferences and see some basic info).
Copy the add_members script to a new name and edit it so that it calls AddMember instead of AddApprovedMember. See Mailman/Cgi/subscribe.py for an example of how to do this and the various exceptions you'll have to catch and handle.
John Dennis <jdennis@redhat.com>
![](https://secure.gravatar.com/avatar/46d27433ede19aa8a6500569fa5e7711.jpg?s=120&d=mm&r=g)
Thanks very much to John for his advice on this. I've implemented it, and am now facing a slightly different problem.
For those just tuning in, I'm using MM 2.1.5 and trying to add new list subscribers via the command line (so users don't see the default MM templates and I have control over the UI). I started off by using PHP to call add_members, which successfully subscribes a user. It goes like this:
[me@HOST]$ echo your@email.com | add_members -r - LISTNAME
I have to use echo because add_members only reads from files or standard input, but otherwise it works wonderfully. The trouble is that no confirmation is sent to the subscriber. John Dennis pointed out that add_members could be copied and hacked so that instead of calling ApprovedAddMember (which doesn't send a confirmation), I could call AddMember (which should generate a confirmation). So I created a modified add_members and swapped this line:
mlist.ApprovedAddMember(userdesc, ack, 0)
with this one:
mlist.AddMember(userdesc, remote="Webpage")
Running the new script on the command line generates this:
Strangest of all, a confirmation message *is* generated and sent to the email address, but clicking on the confirmation link just sends me to a MM error page. I'm at a loss as to what the problem might be.
Thanks to anyone who made it this far. And quadruple thanks to anyone who can help. I appreciate it!
-Ren
On Oct 21, 2005, at 2:41 PM, John Dennis wrote:
![](https://secure.gravatar.com/avatar/746f7519ba02fb0d815e59f305c53fa2.jpg?s=120&d=mm&r=g)
Ren Bucholz wrote:
The problem is that AddMember generates the pending subscription, the cookie and the confirmation email and then raises Errors.MMSubscribeNeedsConfirmation so the caller (generally, Mailman/Cgi/subscribe.py) can catch the exception and generate the appropriate response text. The add_members script doesn't catch this exception, so you get the above error. You can just add
except Errors.MMSubscribeNeedsConfirmation:
print >> tee, _('Sent Confirmation: %(member)s')
or maybe, if you don't actually see this output, just
except Errors.MMSubscribeNeedsConfirmation:
pass
to the excepts following the try: of the AddMember call. You probably want to also handle the Errors.MMNeedApproval exception in case you do this on a list where subscription requires approval.
As to why the confirmation link returned an error, I don't know why this happened. What does Mailman's error log say?
-- Mark Sapiro <msapiro@value.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/46d27433ede19aa8a6500569fa5e7711.jpg?s=120&d=mm&r=g)
This is a followup to an older message, but I wanted to say that Mark's fix worked for the error handling. Thanks, Mark!
I'm still having a problem with the confirmations, however. To recap, I'm trying to use a modified version of add_members (call it new_add_members) in order to subscribe people via my own webform (where PHP executes add_members). I modified it because I'd like the list to be confirmed opt-in, but add_members assumes that the user has confirmed their subscription and doesn't bother with the confirmation message. There's a longer description of what I did in this list's archives, if you're interested: http://www.mail-archive.com/mailman-users@python.org/msg35077.html
The problem is that this script totally breaks Mailman's web subscription features. The first time I run new_add_members, I get a seemingly normal looking confirmation. Upon clicking the confirmation link, I get the Mailman's generic "Sorry, We Hit A Bug!" message. And from that point forward, attempting to subscribe via the list's standard Mailman info page (foo.com/mailman/listinfo/your_list) generates the same error. You can still subscribe by calling the unmodified add_members. The error logs say:
admin(32487): [----- Mailman Version: 2.1.5 -----] admin(32487): [----- Traceback ------] admin(32487): Traceback (most recent call last): admin(32487): File "/usr/lib/mailman/scripts/driver", line 101, in run_main admin(32487): main() admin(32487): File "/usr/lib/mailman/Mailman/Cgi/subscribe.py", line 96, in main admin(32487): process_form(mlist, doc, cgidata, language) admin(32487): File "/usr/lib/mailman/Mailman/Cgi/subscribe.py", line 176, in process_form admin(32487): mlist.AddMember(userdesc, remote) admin(32487): File "/usr/lib/mailman/Mailman/MailList.py", line 854, in AddMember admin(32487): cookie = self.pend_new(Pending.SUBSCRIPTION, userdesc) admin(32487): File "/usr/lib/mailman/Mailman/Pending.py", line 65, in pend_new admin(32487): db = self.__load() admin(32487): File "/usr/lib/mailman/Mailman/Pending.py", line 95, in __load admin(32487): return cPickle.load(fp) admin(32487): AttributeError: 'module' object has no attribute 'UserDesc' admin(32487): [----- Python Information -----] admin(32487): sys.version = 2.3.4 (#1, Feb 2 2005, 11:44:49) [GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)]
If anyone has any idea how to fix this, I'd be most appreciative. I should also mention that error isn't limited to a single address - subscribing me@fake.com via new_add_members will cause a web subscription for you@fake.com to fail. Thanks for reading this far!
-Ren
![](https://secure.gravatar.com/avatar/746f7519ba02fb0d815e59f305c53fa2.jpg?s=120&d=mm&r=g)
Ren Bucholz wrote:
<snip>
At this point, lists/listname/pending.pck is corrupt and has to be removed for normal stuff to proceed.
The underlying problem is new_members defines the UserDesc class to be empty, thus when you call
mlist.AddMember(userdesc, remote="Webpage")
userdesc is not a valid UserDesc instance for AddMember which is where things go wrong.
I think you need to do the following in your script.
Add
from Mailman.UserDesc import UserDesc
Remove
class UserDesc: pass
It looks like that's all you need, but I haven't looked too thoroughly.
-- Mark Sapiro <msapiro@value.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/46d27433ede19aa8a6500569fa5e7711.jpg?s=120&d=mm&r=g)
On Dec 10, 2005, at 2:43 PM, Mark Sapiro wrote:
At this point, lists/listname/pending.pck is corrupt and has to be removed for normal stuff to proceed.
Quick question before trying this fix - can I just erase pending.pck, or do I need to replace it with a non-corrupted version from another list?
Thanks!
-Ren
![](https://secure.gravatar.com/avatar/46d27433ede19aa8a6500569fa5e7711.jpg?s=120&d=mm&r=g)
Mark is officially awesome. This works, and now my list can be confirmed-opt-in. Thanks sooooo much!
-Ren
PS - If you want to see the final, working replacement for Add_Members, you can get it here: http://trubble.com/miscellaneous/new_add_members.txt
On Dec 10, 2005, at 2:43 PM, Mark Sapiro wrote:
![](https://secure.gravatar.com/avatar/46d27433ede19aa8a6500569fa5e7711.jpg?s=120&d=mm&r=g)
One last caveat: following the confirmation link works, as does
confirming your subscription once you get there. However, *cancelling*
your subscription from the website leads to the same "We hit a bug
message." I'm not including the URL in my verify.txt confirmation
message (users just have to reply), but I thought y'all might want to
know about this outstanding issue. Users can always ignore the
confirmation, of course, but errors are unsettling.
Thanks again, and I'm happy to test any suggested fixes that emerge.
-Ren
On Dec 10, 2005, at 3:45 PM, Ren Bucholz wrote:
![](https://secure.gravatar.com/avatar/746f7519ba02fb0d815e59f305c53fa2.jpg?s=120&d=mm&r=g)
Ren Bucholz wrote:
This is a known problem - fixed in 2.1.6. See <http://sourceforge.net/tracker/index.php?func=detail&aid=981188&group_id=103&atid=100103>
-- Mark Sapiro <msapiro@value.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/f07ab66e1cdf0b3862943bafe6b683b1.jpg?s=120&d=mm&r=g)
On Fri, 2005-10-21 at 14:23 -0400, Ren Bucholz wrote:
Not is its current manifestation. The reason is that manual adding of members assumes this is an approved action. You have two choices:
redirect them to the signup page for the list (this has the advantage of allowing the user to set some preferences and see some basic info).
Copy the add_members script to a new name and edit it so that it calls AddMember instead of AddApprovedMember. See Mailman/Cgi/subscribe.py for an example of how to do this and the various exceptions you'll have to catch and handle.
John Dennis <jdennis@redhat.com>
![](https://secure.gravatar.com/avatar/46d27433ede19aa8a6500569fa5e7711.jpg?s=120&d=mm&r=g)
Thanks very much to John for his advice on this. I've implemented it, and am now facing a slightly different problem.
For those just tuning in, I'm using MM 2.1.5 and trying to add new list subscribers via the command line (so users don't see the default MM templates and I have control over the UI). I started off by using PHP to call add_members, which successfully subscribes a user. It goes like this:
[me@HOST]$ echo your@email.com | add_members -r - LISTNAME
I have to use echo because add_members only reads from files or standard input, but otherwise it works wonderfully. The trouble is that no confirmation is sent to the subscriber. John Dennis pointed out that add_members could be copied and hacked so that instead of calling ApprovedAddMember (which doesn't send a confirmation), I could call AddMember (which should generate a confirmation). So I created a modified add_members and swapped this line:
mlist.ApprovedAddMember(userdesc, ack, 0)
with this one:
mlist.AddMember(userdesc, remote="Webpage")
Running the new script on the command line generates this:
Strangest of all, a confirmation message *is* generated and sent to the email address, but clicking on the confirmation link just sends me to a MM error page. I'm at a loss as to what the problem might be.
Thanks to anyone who made it this far. And quadruple thanks to anyone who can help. I appreciate it!
-Ren
On Oct 21, 2005, at 2:41 PM, John Dennis wrote:
![](https://secure.gravatar.com/avatar/746f7519ba02fb0d815e59f305c53fa2.jpg?s=120&d=mm&r=g)
Ren Bucholz wrote:
The problem is that AddMember generates the pending subscription, the cookie and the confirmation email and then raises Errors.MMSubscribeNeedsConfirmation so the caller (generally, Mailman/Cgi/subscribe.py) can catch the exception and generate the appropriate response text. The add_members script doesn't catch this exception, so you get the above error. You can just add
except Errors.MMSubscribeNeedsConfirmation:
print >> tee, _('Sent Confirmation: %(member)s')
or maybe, if you don't actually see this output, just
except Errors.MMSubscribeNeedsConfirmation:
pass
to the excepts following the try: of the AddMember call. You probably want to also handle the Errors.MMNeedApproval exception in case you do this on a list where subscription requires approval.
As to why the confirmation link returned an error, I don't know why this happened. What does Mailman's error log say?
-- Mark Sapiro <msapiro@value.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/46d27433ede19aa8a6500569fa5e7711.jpg?s=120&d=mm&r=g)
This is a followup to an older message, but I wanted to say that Mark's fix worked for the error handling. Thanks, Mark!
I'm still having a problem with the confirmations, however. To recap, I'm trying to use a modified version of add_members (call it new_add_members) in order to subscribe people via my own webform (where PHP executes add_members). I modified it because I'd like the list to be confirmed opt-in, but add_members assumes that the user has confirmed their subscription and doesn't bother with the confirmation message. There's a longer description of what I did in this list's archives, if you're interested: http://www.mail-archive.com/mailman-users@python.org/msg35077.html
The problem is that this script totally breaks Mailman's web subscription features. The first time I run new_add_members, I get a seemingly normal looking confirmation. Upon clicking the confirmation link, I get the Mailman's generic "Sorry, We Hit A Bug!" message. And from that point forward, attempting to subscribe via the list's standard Mailman info page (foo.com/mailman/listinfo/your_list) generates the same error. You can still subscribe by calling the unmodified add_members. The error logs say:
admin(32487): [----- Mailman Version: 2.1.5 -----] admin(32487): [----- Traceback ------] admin(32487): Traceback (most recent call last): admin(32487): File "/usr/lib/mailman/scripts/driver", line 101, in run_main admin(32487): main() admin(32487): File "/usr/lib/mailman/Mailman/Cgi/subscribe.py", line 96, in main admin(32487): process_form(mlist, doc, cgidata, language) admin(32487): File "/usr/lib/mailman/Mailman/Cgi/subscribe.py", line 176, in process_form admin(32487): mlist.AddMember(userdesc, remote) admin(32487): File "/usr/lib/mailman/Mailman/MailList.py", line 854, in AddMember admin(32487): cookie = self.pend_new(Pending.SUBSCRIPTION, userdesc) admin(32487): File "/usr/lib/mailman/Mailman/Pending.py", line 65, in pend_new admin(32487): db = self.__load() admin(32487): File "/usr/lib/mailman/Mailman/Pending.py", line 95, in __load admin(32487): return cPickle.load(fp) admin(32487): AttributeError: 'module' object has no attribute 'UserDesc' admin(32487): [----- Python Information -----] admin(32487): sys.version = 2.3.4 (#1, Feb 2 2005, 11:44:49) [GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)]
If anyone has any idea how to fix this, I'd be most appreciative. I should also mention that error isn't limited to a single address - subscribing me@fake.com via new_add_members will cause a web subscription for you@fake.com to fail. Thanks for reading this far!
-Ren
![](https://secure.gravatar.com/avatar/746f7519ba02fb0d815e59f305c53fa2.jpg?s=120&d=mm&r=g)
Ren Bucholz wrote:
<snip>
At this point, lists/listname/pending.pck is corrupt and has to be removed for normal stuff to proceed.
The underlying problem is new_members defines the UserDesc class to be empty, thus when you call
mlist.AddMember(userdesc, remote="Webpage")
userdesc is not a valid UserDesc instance for AddMember which is where things go wrong.
I think you need to do the following in your script.
Add
from Mailman.UserDesc import UserDesc
Remove
class UserDesc: pass
It looks like that's all you need, but I haven't looked too thoroughly.
-- Mark Sapiro <msapiro@value.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/46d27433ede19aa8a6500569fa5e7711.jpg?s=120&d=mm&r=g)
On Dec 10, 2005, at 2:43 PM, Mark Sapiro wrote:
At this point, lists/listname/pending.pck is corrupt and has to be removed for normal stuff to proceed.
Quick question before trying this fix - can I just erase pending.pck, or do I need to replace it with a non-corrupted version from another list?
Thanks!
-Ren
![](https://secure.gravatar.com/avatar/46d27433ede19aa8a6500569fa5e7711.jpg?s=120&d=mm&r=g)
Mark is officially awesome. This works, and now my list can be confirmed-opt-in. Thanks sooooo much!
-Ren
PS - If you want to see the final, working replacement for Add_Members, you can get it here: http://trubble.com/miscellaneous/new_add_members.txt
On Dec 10, 2005, at 2:43 PM, Mark Sapiro wrote:
![](https://secure.gravatar.com/avatar/46d27433ede19aa8a6500569fa5e7711.jpg?s=120&d=mm&r=g)
One last caveat: following the confirmation link works, as does
confirming your subscription once you get there. However, *cancelling*
your subscription from the website leads to the same "We hit a bug
message." I'm not including the URL in my verify.txt confirmation
message (users just have to reply), but I thought y'all might want to
know about this outstanding issue. Users can always ignore the
confirmation, of course, but errors are unsettling.
Thanks again, and I'm happy to test any suggested fixes that emerge.
-Ren
On Dec 10, 2005, at 3:45 PM, Ren Bucholz wrote:
![](https://secure.gravatar.com/avatar/746f7519ba02fb0d815e59f305c53fa2.jpg?s=120&d=mm&r=g)
Ren Bucholz wrote:
This is a known problem - fixed in 2.1.6. See <http://sourceforge.net/tracker/index.php?func=detail&aid=981188&group_id=103&atid=100103>
-- Mark Sapiro <msapiro@value.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
participants (3)
-
John Dennis
-
Mark Sapiro
-
Ren Bucholz