-
Notifications
You must be signed in to change notification settings - Fork 1
Usage
The main class needed to work with a Mailman list is, not surprisingly, MailmanList
. In order to be useful, this class needs to know the AdminUrl
of a list (e.g., http://foo.com/mailman/admin.cgi/mylist
) and the corresponding Password
.
Once you have a MailmanList
, you can call list.ReadAsync()
to read all of the list's properties from the web interface, and then save list.CurrentConfig
to keep the list's configuration as JSON. list.WriteAsync()
will write all of the current properties to the web interface.
MailmanList
does its work using a MailmanClient
. This class has a number of properties that can be used to customize the way that the web interface is accessed via HTTP:
IAuthenticator Authenticator { get; set; }
X509CertificateCollection ClientCertificates { get; set; }
bool FollowRedirects { get; set; }
int? MaxRedirects { get; set; }
IWebProxy Proxy { get; set; }
int Timeout { get; set; }
string UserAgent { get; set; }
MailmanClient
also exposes the two methods which are used internally to communicate with the web interface: ExecuteAdminRequestAsync()
, and ExecuteRosterRequestAsync()
. You can use these to roll your own Mailman calls.
The core of a MailmanList
is the various section properties, each of which corresponds to a different section of the list's web interface: General
, Password
, Membership
, etc. Most sections follow the same pattern: ReadAsync()
and WriteAsync()
methods to specifically read and write all the properties for that section, and property fields to manipulate the individual properties. For example, to set a new subject prefix for the list, you can do:
await myList.General.ReadAsync();
myList.General.SubjectPrefix = "[MyList]";
await myList.General.WriteAsync();
A few sections offer additional functionality or depart from this model in other ways.
The three password properties in Passwords
will always be blank after you read from the web interface, because of course the web pages don't display the current passwords. For this reason, the JSON configuration for a list also will not include passwords.
This section has a completely different format. The only properties it provides are EmailList
, which is a IEnunmerable<string>
of all the current subscribers, and Emails
, which is the same list as a single string, delimited by newlines.
Membership
also provides the following methods:
ModerateAllAsync();
UnmoderateAllAsync();
// These can be called either with an IEnumerable<string> or with a newline-delimited string
SubscribeAsync();
InviteAsync();
// Can be called as above, or with an IEnumerable<Member>
UnsubscribeAsync();
// Takes a regex and returns an IEnumerable<Member>
SearchMembersAsync();
// Saves properties on an IEnumerable<Member>
SaveMembersAsync();
ChangeMemberAddressAsync(string oldAddress, string newAddress);
The web interface has two settings which cause an action to take place rather than saving a configuration value. These are surfaced as NewVolumeAsync()
and SendDigestNowAsync()
.
The web interface has four subsections under "Privacy Options", but these are rolled up into a single Privacy
section.
Like the Digest
section, this section has a MassCatchupAsync()
method which has the same effect as toggling the corresponding web property.