如何使用 .Net 连接到 Mailman 邮件列表
我必须开发一个 .Net 应用程序,在其中我必须从 Mailman 邮件列表中添加或删除用户。我的问题是是否有任何 .Net 连接器或 Dll 可以使用 .Net 连接到 mailman 邮件列表。
I have to develop a .Net application in which i have to add or remove a user from Mailman mailing list.My Question is whether there is any .Net connector or Dll to connect to mailman mailing list using .Net.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑 (9/21/14): 我刚刚发布了一个 NuGet 包,用于通过 HTTP 调用操作 Mailman v2 列表的大部分方面。 https://www.nuget.org/packages/MailmanSharp/
我不知道任何现有组件都可以执行此操作,但由于 Mailman 界面全部位于 Web 上,因此您可以使用 HttpWebRequest“控制”它;我最近编写了一个小应用程序,它可以检索订阅者列表、订阅/取消订阅人员以及设置单独的标志,例如中等/无邮件/等。需要在 Mailman 页面的源代码中进行一些探索才能了解需要在 POST 中设置哪些变量,并进行一些试验和错误。我建议设置一个临时邮件列表来玩。
为了完成大部分工作,您需要一个持久的 CookieContainer,您可以将其连接到不同的 HttpWebRequest;第一个调用是使用管理员密码对管理页面进行 POST,以设置允许您访问其他页面的会话 cookie。
有些 POST 是常规的 application/x-www-form-urlencoded 类型,但有些也是 multipart/form-data。对于后者,我在 http://www. briangrinstead.com/blog/multipart-form-post-in-c 我必须进行一些更改,以便可以传入我的 CookieContainer
以下是一些示例代码:
Edit (9/21/14): I have just released a NuGet package for manipulating most aspects of a Mailman v2 list via HTTP calls. https://www.nuget.org/packages/MailmanSharp/
I'm not aware of any existing component to do this, but since the Mailman interface is all on the web, you can "control" it with HttpWebRequest; I recently wrote a small app which can retrieve the subscriber list, subscribe/unsubscribe people, and set individual flags like moderate/nomail/etc. It takes a little poking around in the source of the Mailman pages to see what variables need to be set in the POST, and some trial and error. I suggest setting up a temp Mailman list just to play with.
In order to do most of this, you'll need a persistent CookieContainer that you can hook up to your different HttpWebRequests; the first call is a POST to the admin page with the admin password to set the session cookie that gives you access to the other pages.
Some of the POSTs are regular application/x-www-form-urlencoded types, but some are also multipart/form-data. For the latter, I found some very helpful code at http://www.briangrinstead.com/blog/multipart-form-post-in-c I had to make a couple of changes so that I could pass in my CookieContainer
Here's some sample code: