Revision 1 as of 2008-05-27 13:24:16

Clear message

3.13. How do I remove a user name or email address with an illegal character in it (or Mixed or Upper case domain)?

This sort of thing might result in a subscriber address being corrupted, and errors like this:

Traceback (most recent call last):

  File "/usr/local/mailman/scripts/driver", line 87, in run_main
    main()
  File "/usr/local/mailman/Mailman/Cgi/admin.py", line 198, in main
    show_results(mlist, doc, category, subcat, cgidata)
  File "/usr/local/mailman/Mailman/Cgi/admin.py", line 501, in show_results
    form.AddItem(membership_options(mlist, subcat, cgidata, doc, form))
  File "/usr/local/mailman/Mailman/Cgi/admin.py", line 873, in membership_options
    all = [_m.encode() for _m in mlist.getMembers()]
  UnicodeDecodeError: 'ascii' codec can't decode byte 0xa0 in position 22: ordinal not in range(128)
  • Before trying the method(s) below, first try

 % bin/list_members -i listname

If that lists the addresses you want removed, try

 % bin/list_members -i listname | bin/remove_members -f - listname
  • To fix this, try using bin/withlist.

If you have a bad address such as "na,me@example.com" that should be corrected to "name@example.com" you would do the following:

 % bin/withlist -l mylist
 >>> m.removeMember('na,me@example.com')
 >>> m.Save()
 >>> ^D

This is the preferred method since it cleans out any other information in the database associated with the bogus address, but if it raises exceptions and doesn't remove the member you should do one of the following (and submit a bug report!)

If the member is a regular member

 % bin/withlist -l mylist
 >>> del m.members['na,me@example.com']
 >>> m.Save()
 >>> ^D

If the member is a digest member

 % bin/withlist -l mylist
 >>> del m.digest_members['na,me@example.com']
 >>> m.Save()
 >>> ^D

Email addresses may only contain ASCII characters. Older versions of Mailman allowed non-ASCII characters as email addresses sometimes. This has since been fixed, but some older lists may have bogus addresses in them. Here's a command line recipe that might help clear all of these out:

 % bin/find_member -l listname "[^\w\-+@.%]" > file

This will give you an list of bad addresses, but you will need to edit the list to remove language such as 'found in', etc to make it only a list of email addresses that can be used by the following command:

 % bin/remove_members -f file listname

Also, you may need to adjust the regular expression used by find_member.

If you are told when trying to remove the invalid members that the invalid members do not exist, instead of saving the invalid members to a file first which can cause problems with some invalid characters, you can use a pipe to do this in one step:

 % bin/list_members -i listname | bin/remove_members -f - listname

If the above methods don't work, you can try

 % bin/list_members -f listname | grep -v -e 'pattern' | bin/sync_members -f - listname

where listname is the name of the list and pattern is a pattern that will match the bad address. Alternatively, you can direct the output of bin/list_members to a file, edit the file to remove the unwanted address(es) and than use it as input to bin/sync_members.

Last changed on Sun May 11 17:07:11 2008 by Mark Sapiro Converted from the Mailman FAQ Wizard

This is one of many Frequently Asked Questions.