From b140c056546efdfa69fa48098db8eef7b45077c0 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 24 Jul 2014 14:45:29 +0200 Subject: Adding examples and documents --- docs/01-leafnode-list-pygn-as-mail2news.html | 148 ++++++++++++ docs/02-leafnode-list-pygn-as-mail2news.html | 85 +++++++ docs/joerg01.eml | 145 +++++++++++ docs/mail2news-gateway | 268 +++++++++++++++++++++ examples/drhyde-news2mail-and-mail2news/LICENCE | 3 + examples/drhyde-news2mail-and-mail2news/mail2news | 58 +++++ examples/drhyde-news2mail-and-mail2news/news2mail | 177 ++++++++++++++ .../yapc-europe-2007-paper.pdf | Bin 0 -> 82566 bytes .../yapc-europe-2007-paper.pod | 177 ++++++++++++++ 9 files changed, 1061 insertions(+) create mode 100644 docs/01-leafnode-list-pygn-as-mail2news.html create mode 100644 docs/02-leafnode-list-pygn-as-mail2news.html create mode 100644 docs/joerg01.eml create mode 100644 docs/mail2news-gateway create mode 100644 examples/drhyde-news2mail-and-mail2news/LICENCE create mode 100644 examples/drhyde-news2mail-and-mail2news/mail2news create mode 100644 examples/drhyde-news2mail-and-mail2news/news2mail create mode 100644 examples/drhyde-news2mail-and-mail2news/yapc-europe-2007-paper.pdf create mode 100644 examples/drhyde-news2mail-and-mail2news/yapc-europe-2007-paper.pod diff --git a/docs/01-leafnode-list-pygn-as-mail2news.html b/docs/01-leafnode-list-pygn-as-mail2news.html new file mode 100644 index 0000000..a582b0d --- /dev/null +++ b/docs/01-leafnode-list-pygn-as-mail2news.html @@ -0,0 +1,148 @@ + + + + [leafnode-list] pygn as a mail2news gateway + + + + + + + + + +

[leafnode-list] pygn as a mail2news gateway

+ Matej Cepl + ceplm at seznam.cz +
+ Fri Sep 1 05:26:49 CEST 2006 +

+
+ +
Hi,
+
+so now the real problem I am dealing with -- mail2news bidirectional
+gateway.
+
+On leafnode 1.* I used mail2news patch by Nikita Youschenko
+(http://zigzag.lvk.cs.msu.su/leafnode/ -- I wonder something like that has
+not been included in leafnode 2.*, it would make great fit IMHO, but I know
+I am not a programmer, and I won't do it, so I shut up on this), so I have
+to install some mail2news gateway. I tried pygn (just because it is
+packaged for Debian; any other suggestions?), but I haven't managed to
+configured it yet. This is what I did (with expected workflow):
+
+1) mail is read by my kmail (user matej) and if it is list message which
+should be gatewayed to news, it is bounced to news at localhost -- this step
+has been working perfectly for couple of years and it has not been changed.
+
+2) news' .procmailrc contains a lot of rules like this (for news2mail):
+
+ARG = $1
+
+:0 bh:
+* ARG ?? local-mail-comp-boston
+| pygn2m -l $HOME/log-pygn2m -d -t discuss at blu.org -s ceplm at seznam.cz
+
+and like this (for mail2news):
+
+:0 bh:
+* ^List-Id:.*pkg-lyx-devel.lists.alioth.debian.org
+| pygm2n  -l $HOME/log-pygm2n -d -n local.mail.comp.lyx-debian
+
+/etc/news/local.groups is this:
+
+local.mail.comp.cambridge       m       Cambridge (UK) LUG
+local.mail.comp.boston  m       Boston LUG
+local.mail.comp.surrey  m       Surrey LUG
+local.mail.comp.bosto-admin     m       Boston admins
+local.mail.comp.oxford  m       Oxford LUG
+local.mail.comp.lyx-debian      m       Maintainer of LyX on Debian
+local.mail.comp.scottish        m       Scottish LUG
+local.mail.comp.northwales      m       NWales LUG
+local.mail.comp.southwales      m       SWales LUG
+local.mail.comp.czdebian        m       Diskuse českých uživatel Debianu
+local.mail.vcfc.random  m       Random list z VCFC
+local.mail.vcfc.branik  m       Diskuse ČCE Braník
+local.mail.soc.oakeshott        m       Conversation -- discussion about Oakeshott
+local.mail.soc.read-only        m       různá RO sociologie
+local.mail.zpravy       m       NG pro různé zpravodajství
+local.test      m       testing group
+
+and this is /etc/news/moderators (w/o comments):
+
+## Public hierarchies with exceptions.
+fido7.*:%s at fido7.ru
+ffm.*:%s at moderators.arcornews.de
+fj.*:%s at moderators.fj-news.org
+medlux.*:%s at news.medlux.ru
+nl.*:%s at nl.net
+relcom.*:%s at moderators.relcom.ru
+ukr.*:%s at sita.kiev.ua
+
+# local groups are moderated by news at localhost
+local.*:news+%s at localhost
+
+# and all gmane stuff should be posted directly
+# gmane does its own thing on it
+gmane.*:
+
+## Direct all other public hierarchies to the master moderator database.
+*:%s at moderators.isc.org
+
+Even though (according to ~news/log-procmail) all messages seem to be
+running correctly, I don't get a message with moderated newsgroups.
+However, without moderating newsgroups, I don't know how to make work
+sending emails from leafnode to email.
+
+Any thoughts or help, please?
+
+Best,
+
+Matěj
+
+-- 
+GPG Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC
+http://www.ceplovi.cz/matej/blog/, Jabber: ceplma at jabber.cz
+23 Marion St. #3, (617) 876-1259, ICQ 132822213
+ 
+Home is where ~/.bashrc is.
+   -- from Usenet
+-------------- next part --------------
+An embedded and charset-unspecified text was scrubbed...
+Name: .procmailrc
+Url: http://www.dt.e-technik.uni-dortmund.de/pipermail/leafnode-list/attachments/20060831/47d485c1/attachment.txt 
+
+ + +
+

+ +
+More information about the leafnode-list +mailing list
+ diff --git a/docs/02-leafnode-list-pygn-as-mail2news.html b/docs/02-leafnode-list-pygn-as-mail2news.html new file mode 100644 index 0000000..886d064 --- /dev/null +++ b/docs/02-leafnode-list-pygn-as-mail2news.html @@ -0,0 +1,85 @@ + + + + [leafnode-list] Re: pygn as a mail2news gateway + + + + + + + + + +

[leafnode-list] Re: pygn as a mail2news gateway

+ Matej Cepl + ceplm at seznam.cz +
+ Fri Sep 1 19:35:16 CEST 2006 +

+
+ +
Matej Cepl wrote:
+> so now the real problem I am dealing with -- mail2news bidirectional
+> gateway.
+
+I tried everything, but I am just not able to make it working. So I have to
+ask again: is there any leafnode-style (aka "for dummies") HOWTO for
+mail2news bi-directional gateway? The most far I got is that I have all my
+local newsgroups unmoderated, so I at least get messages to them. When I
+switch them to moderated, a) I don't get any messages to read, b) no
+messages are posted anyway. Details of how I tried (see above in this
+thread).
+
+Can anybody help me please?
+
+Thanks a lot,
+
+Matěj
+
+-- 
+GPG Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC
+http://www.ceplovi.cz/matej/blog/, Jabber: ceplma at jabber.cz
+23 Marion St. #3, (617) 876-1259, ICQ 132822213
+ 
+See, when the GOVERNMENT spends money, it creates jobs; whereas
+when the money is left in the hands of TAXPAYERS, God only knows
+what they do with it. Bake it into pies, probably. Anything to
+avoid creating jobs.
+    -- Dave Barry
+
+
+
+ + +
+

+ +
+More information about the leafnode-list +mailing list
+ diff --git a/docs/joerg01.eml b/docs/joerg01.eml new file mode 100644 index 0000000..3b13030 --- /dev/null +++ b/docs/joerg01.eml @@ -0,0 +1,145 @@ +Path: news.gmane.org!not-for-mail +From: Joerg Dietrich +Newsgroups: gmane.network.leafnode +Subject: Re: status of leafnode 2 and how to upgrade from + leafnode 1 +Date: Wed, 16 Aug 2006 16:15:54 +0200 +Lines: 60 +Approved: news@gmane.org +Message-ID: <20060816141554.GA30999@leviathan.homedns.org> +References: + +NNTP-Posting-Host: main.gmane.org +Mime-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +X-Trace: sea.gmane.org 1155748787 14017 80.91.229.2 (16 Aug 2006 17:19:47 GMT) +X-Complaints-To: usenet@sea.gmane.org +NNTP-Posting-Date: Wed, 16 Aug 2006 17:19:47 +0000 (UTC) +Original-X-From: leafnode-list-bounces+gnl-leafnode-list=m.gmane.org-DcxqERLcJkQeCZckdHr3IYGCWcDMi6xaD8jGkxKTr40@public.gmane.org Wed Aug 16 19:19:42 2006 +Return-path: +Envelope-to: gnl-leafnode-list@m.gmane.org +Original-Received: from krusty.dt.e-technik.uni-dortmund.de ([129.217.163.1]) + by ciao.gmane.org with esmtp (Exim 4.43) + id 1GDP3I-0004At-B1 + for gnl-leafnode-list@m.gmane.org; Wed, 16 Aug 2006 19:19:36 +0200 +Original-Received: from krusty.dt.e-technik.uni-dortmund.de (localhost [127.0.0.1]) + by mail.dt.e-technik.uni-dortmund.de (Postfix) with ESMTP id E257285FB49 + for ; Wed, 16 Aug 2006 19:19:35 +0200 (CEST) +X-Original-To: leafnode-list-DcxqERLcJkQeCZckdHr3IYGCWcDMi6xaD8jGkxKTr40@public.gmane.org +Delivered-To: leafnode-list-DcxqERLcJkQeCZckdHr3IYGCWcDMi6xaD8jGkxKTr40@public.gmane.org +Original-Received: from localhost (localhost [127.0.0.1]) + by mail.dt.e-technik.uni-dortmund.de (Postfix) with ESMTP id + 692D185FB46 for ; + Wed, 16 Aug 2006 19:19:32 +0200 (CEST) +Original-Received: from krusty.dt.e-technik.uni-dortmund.de ([127.0.0.1]) + by localhost (krusty [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 09436-03 for ; + Wed, 16 Aug 2006 19:19:29 +0200 (CEST) +Original-Received: from nx5.hrz.uni-dortmund.de (nx5.HRZ.Uni-Dortmund.DE + [129.217.131.21]) + by mail.dt.e-technik.uni-dortmund.de (Postfix) with ESMTP id + 9450585FE4E for ; + Wed, 16 Aug 2006 19:19:27 +0200 (CEST) +Original-Received: from ws6-3.us4.outblaze.com (ws6-3.us4.outblaze.com [205.158.62.199]) + by nx5.hrz.uni-dortmund.de (Postfix) with SMTP id 6E9BA4AA5F7 + for ; + Wed, 16 Aug 2006 18:54:36 +0200 (MET DST) +Original-Received: (qmail 12849 invoked from network); 16 Aug 2006 14:16:00 -0000 +Original-Received: from unknown (HELO leviathan.homedns.org) + (joerg-FR+SGtcfUjXk1uMJSBkQmQ@public.gmane.org@80.136.237.253) + by ws6-3.us4.outblaze.com with SMTP; 16 Aug 2006 14:15:58 -0000 +Original-Received: from leviathan.homedns.org (nobody@localhost [127.0.0.1]) + by leviathan.homedns.org (8.13.7/8.13.7) with ESMTP id k7GEFs5l031057 + for ; + Wed, 16 Aug 2006 16:15:55 +0200 +Original-Received: (from joerg@localhost) + by leviathan.homedns.org (8.13.7/8.12.11/Submit) id k7GEFsZg031053 + for leafnode-list-DcxqERLcJkQeCZckdHr3IYGCWcDMi6xaD8jGkxKTr40@public.gmane.org; + Wed, 16 Aug 2006 16:15:54 +0200 +Original-To: leafnode-list-DcxqERLcJkQeCZckdHr3IYGCWcDMi6xaD8jGkxKTr40@public.gmane.org +Mail-Followup-To: leafnode-list-DcxqERLcJkQeCZckdHr3IYGCWcDMi6xaD8jGkxKTr40@public.gmane.org +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.11 +X-Virus-Scanned: amavisd-new at dt.e-technik.uni-dortmund.de +X-Spam-Status: No, hits=0.001 tagged_above=0 required=7 + tests=[UNPARSEABLE_RELAY=0.001] +X-Spam-Level: +X-BeenThere: leafnode-list-DcxqERLcJkQeCZckdHr3IYGCWcDMi6xaD8jGkxKTr40@public.gmane.org +X-Mailman-Version: 2.1.8 +Precedence: list +List-Id: Discussions on the Leafnode Usenet software package + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Original-Sender: leafnode-list-bounces+gnl-leafnode-list=m.gmane.org-DcxqERLcJkQeCZckdHr3IYGCWcDMi6xaD8jGkxKTr40@public.gmane.org +Errors-To: leafnode-list-bounces+gnl-leafnode-list=m.gmane.org-DcxqERLcJkQeCZckdHr3IYGCWcDMi6xaD8jGkxKTr40@public.gmane.org +Xref: news.gmane.org gmane.network.leafnode:3524 +Archived-At: + +On Mon, Aug 14, 2006 at 11:14:01AM +0200, Matthias Andree wrote: +> fetches group articles faster (thanks to pipelining ARTICLE or +> HEAD/BODY commands). + +Which was a big issue when Cornelius and I worked on this in +1999/2000 when many people still had expensive dial-up +connections that were not fully utilized by fetchnews. + +> Official mail2news gatewaying isn't integrated and probably suffers from +> the usual "Message-ID are unique per server" problem that impairs messages +> sent to several lists at the same time. I don't know the state of J=F6rg +> Dietrich's prior works or views on this either. + +I run a mail2news gateway for three or four mailing lists on my +computer. I wrote a python programme for this. It is available +from . The +program lacks documentation and testing by a wider audience, +which is the reason for its "alpha status". However, the program +has been working for me for the last 2 years without any need of +intervention. But I have very little feedback from others. + +Mail2news.py tries to circumvent the problem of unique +Message-IDs by cross-posting to newsgroups corresponding to the +mailing lists the original mail was sent to. Because +cross-mailing does not happen with the few mailing list I am +subscribed to this feature is anything but well tested. + +> It is alpha because I don't care too much for compatibility between +> leafnode-2 versions until I'm happy with it (not much work has been done +> to leafnode-2 in the past weeks since I've been busy with difficult +> fetchmail bug fixes). Else, I know of few bugs that hinder daily +> personal use and am usually quick to fix bugs given the report is +> substantiated (for instance, with a stack backtrace). + +As someone who contributed a substantial amount of code in the +past, I find this a very frustrating status. Since 2000 leafnode-2 +provides significant improved features over leafnode-1. I have +been using leafnode-2 in production mode for four or five years +now. I really do not understand what keeps you from releasing it +instead of keeping it in alpha stage for 5 years and still +supporting leafnode-1, which has been technically obsoleted by +many improvements in leafnode-2. + +Cheers, + Jo:rg + +-- = + + ---=3D=3D=3D Encrypted mail preferred. Key-ID: 1024D/2B693EBF =3D= +=3D=3D--- +Fortune cookie of the day: +A clash of doctrine is not a disaster -- it is an opportunity. +-- = + +_______________________________________________ +leafnode-list mailing list +leafnode-list-DcxqERLcJkQeCZckdHr3IYGCWcDMi6xaD8jGkxKTr40@public.gmane.org +https://www.dt.e-technik.uni-dortmund.de/mailman/listinfo/leafnode-list +http://leafnode.sourceforge.net/ + diff --git a/docs/mail2news-gateway b/docs/mail2news-gateway new file mode 100644 index 0000000..1c57406 --- /dev/null +++ b/docs/mail2news-gateway @@ -0,0 +1,268 @@ +From ceplm@seznam.cz Fri Sep 1 13:51:25 2006 +Message-Id: +From: Matej Cepl +Subject: pygn as a mail2news gateway +Newsgroups: gmane.network.leafnode +Date: Thu, 31 Aug 2006 23:26:49 -0400 +User-Agent: KNode/0.10.2 +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="nextPart1312693.60ImoN5RI4" +Content-Transfer-Encoding: 7Bit +Status: RO +Content-Length: 7709 +Lines: 247 + +--nextPart1312693.60ImoN5RI4 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: 8Bit + +Hi, + +so now the real problem I am dealing with -- mail2news bidirectional +gateway. + +On leafnode 1.* I used mail2news patch by Nikita Youschenko +(http://zigzag.lvk.cs.msu.su/leafnode/ -- I wonder something like that has +not been included in leafnode 2.*, it would make great fit IMHO, but I know +I am not a programmer, and I won't do it, so I shut up on this), so I have +to install some mail2news gateway. I tried pygn (just because it is +packaged for Debian; any other suggestions?), but I haven't managed to +configured it yet. This is what I did (with expected workflow): + +1) mail is read by my kmail (user matej) and if it is list message which +should be gatewayed to news, it is bounced to news@localhost -- this step +has been working perfectly for couple of years and it has not been changed. + +2) news' .procmailrc contains a lot of rules like this (for news2mail): + +ARG = $1 + +:0 bh: +* ARG ?? local-mail-comp-boston +| pygn2m -l $HOME/log-pygn2m -d -t discuss@blu.org -s ceplm@seznam.cz + +and like this (for mail2news): + +:0 bh: +* ^List-Id:.*pkg-lyx-devel.lists.alioth.debian.org +| pygm2n -l $HOME/log-pygm2n -d -n local.mail.comp.lyx-debian + +/etc/news/local.groups is this: + +local.mail.comp.cambridge m Cambridge (UK) LUG +local.mail.comp.boston m Boston LUG +local.mail.comp.surrey m Surrey LUG +local.mail.comp.bosto-admin m Boston admins +local.mail.comp.oxford m Oxford LUG +local.mail.comp.lyx-debian m Maintainer of LyX on Debian +local.mail.comp.scottish m Scottish LUG +local.mail.comp.northwales m NWales LUG +local.mail.comp.southwales m SWales LUG +local.mail.comp.czdebian m Diskuse českých uživatel Debianu +local.mail.vcfc.random m Random list z VCFC +local.mail.vcfc.branik m Diskuse ČCE Braník +local.mail.soc.oakeshott m Conversation -- discussion about Oakeshott +local.mail.soc.read-only m různá RO sociologie +local.mail.zpravy m NG pro různé zpravodajství +local.test m testing group + +and this is /etc/news/moderators (w/o comments): + +## Public hierarchies with exceptions. +fido7.*:%s@fido7.ru +ffm.*:%s@moderators.arcornews.de +fj.*:%s@moderators.fj-news.org +medlux.*:%s@news.medlux.ru +nl.*:%s@nl.net +relcom.*:%s@moderators.relcom.ru +ukr.*:%s@sita.kiev.ua + +# local groups are moderated by news@localhost +local.*:news+%s@localhost + +# and all gmane stuff should be posted directly +# gmane does its own thing on it +gmane.*: + +## Direct all other public hierarchies to the master moderator database. +*:%s@moderators.isc.org + +Even though (according to ~news/log-procmail) all messages seem to be +running correctly, I don't get a message with moderated newsgroups. +However, without moderating newsgroups, I don't know how to make work +sending emails from leafnode to email. + +Any thoughts or help, please? + +Best, + +Matěj + +-- +GPG Finger: 89EF 4BC6 288A BF43 1BAB 25C3 E09F EF25 D964 84AC +http://www.ceplovi.cz/matej/blog/, Jabber: ceplma@jabber.cz +23 Marion St. #3, (617) 876-1259, ICQ 132822213 + +Home is where ~/.bashrc is. + -- from Usenet + +--nextPart1312693.60ImoN5RI4 +Content-Type: text/plain; name=".procmailrc" +Content-Transfer-Encoding: 8Bit +Content-Disposition: attachment; filename=".procmailrc" + +PATH=/bin:/usr/bin:/usr/bin +LOGFILE=$HOME/log-procmail +VERBOSE=yes + +# Note: The $1 contains value only _IF_ procmail +# is invoked with option -m or -a (with an argument). +# Be sure procmail is invoked with that oprion either as from +# LDA or ~/.forward. +# +# $1 is pseudo variable and it can't be used in condition line, +# so we copy the value to ARG. + +ARG = $1 + +#:0 fwh +#* ! ^List-Post: +#* ^Mailing-List: +#| sed -e '/^-\{6,\}\s*Yahoo\!\s*Groups\s*Sponsor/,$d' yahoo-groups-message.txt \ +#| sed -e :a -e '/^\n*$/{$d;N;};/\n$/ba' + +:0 bh: +* ARG ?? local-mail-comp-boston +| pygn2m -l $HOME/log-pygn2m -d -t discuss@blu.org -s ceplm@seznam.cz + +:0 bh: +* ARG ?? local-mail-comp-lyx-debian +| pygn2m -l $HOME/log-pygn2m -d -t pkg-lyx-devel@lists.alioth.debian.org -s ceplm@seznam.cz + +:0 bh: +* ARG ?? local-mail-comp-boston +| pygn2m -l $HOME/log-pygn2m -d -t discuss@blu.org -s ceplm@seznam.cz + +:0 bh: +* ARG ?? local-mail-comp-bosto-admin +| pygn2m -l $HOME/log-pygn2m -d -t bblisa@bblisa.org -s ceplm@seznam.cz + +:0 bh: +* ARG ?? local-mail-comp-surrey +| pygn2m -l $HOME/log-pygn2m -d -t surrey@mailman.lug.org.uk -s ceplm@seznam.cz + +:0 bh: +* ARG ?? local-mail-comp-scottish +| pygn2m -l $HOME/log-pygn2m -d -t scottish@mailman.lug.org.uk -s ceplm@seznam.cz + +:0 bh: +* ARG ?? local-mail-comp-northwales +| pygn2m -l $HOME/log-pygn2m -d -t northwales@mailman.lug.org.uk -s ceplm@seznam.cz + +:0 bh: +* ARG ?? local-mail-comp-southwales +| pygn2m -l $HOME/log-pygn2m -d -t discuss@swlug.org -s ceplm@seznam.cz + +:0 bh: +* ARG ?? local-mail-comp-oxford +| pygn2m -l $HOME/log-pygn2m -d -t oxlug@lists.oxlug.org -s ceplm@seznam.cz + +:0 bh: +* ARG ?? local-mail-comp-cambridge +| pygn2m -l $HOME/log-pygn2m -d -t clug@cambridge-lug.org -s ceplm@seznam.cz + +:0 bh: +* ARG ?? local-mail-comp-czdebian +| pygn2m -l $HOME/log-pygn2m -d -t czdebian-l@debian.cz -s ceplm@seznam.cz + +:0 bh: +* ARG ?? local-mail-vcfc-random +| pygn2m -l $HOME/log-pygn2m -d -t vcfgb-random@yahoogroups.com -s ceplm@seznam.cz + +:0 bh: +* ARG ?? local-mail-vcfc-branik +| pygn2m -l $HOME/log-pygn2m -d -t cebranik@pandora.cz -s ceplm@seznam.cz + +:0 bh: +* ARG ?? local-mail-soc-goffman +| pygn2m -l $HOME/log-pygn2m -d -t goffman@mail.lsit.ucsb.edu -s ceplm@seznam.cz + +:0 bh: +* ARG ?? local-mail-soc-oakeshott +| pygn2m -l $HOME/log-pygn2m -d -t conversation@jiscmail.ac.uk -s ceplm@seznam.cz + +:0 bh: +* ARG ?? local-test +| pygn2m -l $HOME/log-pygn2m -d -t matej@localhost -s ceplm@seznam.cz + +:0 bh: +* ^Subject: *test +| pygm2n -l $HOME/log-pygm2n -d -n local.test + +:0 bh: +* ^List-Id:.*pkg-lyx-devel.lists.alioth.debian.org +| pygm2n -l $HOME/log-pygm2n -d -n local.mail.comp.lyx-debian + +:0 bh: +* ^List-Id:.*discuss.blu.org +| pygm2n -l $HOME/log-pygm2n -d -n local.mail.comp.boston + +:0 bh: +* ^List-Id:.*bblisa.bblisa.org +| pygm2n -l $HOME/log-pygm2n -d -n local.mail.comp.bosto-admin + +:0 bh: +* ^List-Id:.*surrey.mailman.lug.org.uk +| pygm2n -l $HOME/log-pygm2n -d -n local.mail.comp.surrey + +:0 bh: +* ^List-Id:.*scottish.mailman.lug.org.uk +| pygm2n -l $HOME/log-pygm2n -d -n local.mail.comp.scottish + +:0 bh: +* ^List-Id:.*northwales.mailman.lug.org.uk +| pygm2n -l $HOME/log-pygm2n -d -n local.mail.comp.northwales + +:0 bh: +* ^List-Id:.*discuss.swlug.org +| pygm2n -l $HOME/log-pygm2n -d -n local.mail.comp.southwales + +:0 bh: +* ^List-Id:.*oxlug.lists.oxlug.org +| pygm2n -l $HOME/log-pygm2n -d -n local.mail.comp.oxford + +:0 bh: +* ^List-Id:.*clug.cambridge-lug.org +| pygm2n -l $HOME/log-pygm2n -d -n local.mail.comp.cambridge + +:0 bh: +* ^List-Id:.*czdebian-l.debian.cz +| pygm2n -l $HOME/log-pygm2n -d -n local.mail.comp.czdebian + +:0 bh: +* ^Mailing-List:.*(vcfgb|vcfc)-(announce|random)@yahoogroups.com +| pygm2n -l $HOME/log-pygm2n -d -n local.mail.vcfc.random + +:0 bh: +* ^List-Post:.*cebranik@pandora.cz +| pygm2n -l $HOME/log-pygm2n -d -n local.mail.vcfc.branik + +:0 bh: +* ^List-Post:.*goffman.mail.lsit.ucsb.edu +| pygm2n -l $HOME/log-pygm2n -d -n local.mail.soc.goffman + +:0 bh: +* ^To:.*CONVERSATION@JISCMAIL.AC.UK +| pygm2n -l $HOME/log-pygm2n -d -n local.mail.soc.oakeshott + +:0 bh: +* ^To:.*(@JISCMAIL.AC.UK|PILN@COLUMBIA.EDU|UMD-LPBR-FULL@LISTSERV.UMD.EDU) +| pygm2n -l $HOME/log-pygm2n -d -n local.mail.soc.read-only + +:0 bh: +* ^From:.*(googlealerts-noreply@google.com|alerts@yahoo-inc.com|robot@radio.cz) +| pygm2n -l $HOME/log-pygm2n -d -n local.mail.zpravy + +--nextPart1312693.60ImoN5RI4-- + + diff --git a/examples/drhyde-news2mail-and-mail2news/LICENCE b/examples/drhyde-news2mail-and-mail2news/LICENCE new file mode 100644 index 0000000..46961de --- /dev/null +++ b/examples/drhyde-news2mail-and-mail2news/LICENCE @@ -0,0 +1,3 @@ +The news2mail and mail2news scripts are licenced under the same terms as perl itself. + +All other files in this directory may be used and distributed by anyone but may not be modified. diff --git a/examples/drhyde-news2mail-and-mail2news/mail2news b/examples/drhyde-news2mail-and-mail2news/mail2news new file mode 100644 index 0000000..1f026a0 --- /dev/null +++ b/examples/drhyde-news2mail-and-mail2news/mail2news @@ -0,0 +1,58 @@ +#!/usr/local/bin/perl + +use warnings; +use strict; + +use Data::Dumper; +use Net::NNTP; +use News::Article; + +use constant DEBUG => 0; + +select(STDERR); $| = 1; select(STDOUT); + +die("mail2news hasn't been configured.\n") unless(-r '/etc/mail2newsrc'); + +my $subs = { do '/etc/mail2newsrc' }; + +my $group = shift; +die("mail2news must be told what group to post to\n") unless($group); + +my $article = News::Article->new(); +$article->read(\*STDIN); +$article->set_headers(Newsgroups => $group); +$article->drop_headers(qw(date to received)); +$article->add_date(); + +my $posted_ok = 0; +foreach my $server (grep { $subs->{$_}->{$group} } keys %{$subs}) { + my($auth, $host) = split('@', $server); + ($auth, $host) = (':', $auth) if(!$host); + my($user, $pass) = split(':', $auth); + ($host, my $port) = split(':', $host); + $port ||= 119; + + my $client = Net::NNTP->new($host, Port => $port); + $client->authinfo($user => $pass) if($user); + + unless($client->postok()) { + print STDERR "mail2news configured to post to $group via\n". + "$server, but it didn't say we can post. Bother and damnation!\n"; + next; + } + + eval { $article->post($client); }; + die("Error in posting to $server: $@\n") if($@); + $posted_ok++; +} + +if(!$posted_ok) { + die "mail2news couldn't post to $group on any configured server.\n\n". + "Your message read:\n\n". + join("\n\n", + join("\n", $article->headers()), + join("\n", $article->body()) + )."\n\n". + "And the environment was:\n\n". + join("\n", map { join(":\t", $_, $ENV{$_}) } sort keys %ENV); +} diff --git a/examples/drhyde-news2mail-and-mail2news/news2mail b/examples/drhyde-news2mail-and-mail2news/news2mail new file mode 100644 index 0000000..e91bea6 --- /dev/null +++ b/examples/drhyde-news2mail-and-mail2news/news2mail @@ -0,0 +1,177 @@ +#!/usr/local/bin/perl + +use strict; +use warnings; + +use Net::NNTP::Client; +use GDBM_File; +use Email::Send; +use Data::Dumper; + +use constant DEBUG => 0; + +select(STDERR); $| = 1; select(STDOUT); + +my $confdir = "$ENV{HOME}/.news2mail"; +unless(-d $confdir && -f $confdir.'/config.pl') { + mkdir $confdir || die("Couldn't create $confdir\n"); + open(FILE, ">$confdir/config.pl") || die("Couldn't create $confdir/config.pl\n"); + print FILE join("\n", + "smtphost => 'localhost',", + "address => 'myaddress\@example.com',", + "'user:pass\@news.example.com:119' => {", + " 'misc.test' => { post => 1 },", + " 'alt.config' => { post => 1 },", + "},", + "'privateserver.localdomain' => {", + " 'my.secret.newsgroup' => { post => 1 },", + "}" + ); + close(FILE); + + print "You need to configure me! Take a look in $confdir\n"; + exit; +} + +tie my %seen, 'GDBM_File', "$confdir/seen.dbm", GDBM_WRCREAT, 0640; + +my $subscriptions = { do $confdir.'/config.pl' }; + +my $smtphost = $subscriptions->{smtphost}; +my $address = $subscriptions->{address}; +delete $subscriptions->{smtphost}; +delete $subscriptions->{address}; + +SERVERS: foreach my $server (keys %{$subscriptions}) { + unless(-d "$confdir/$server") { + mkdir("$confdir/$server") || die("Can't create $confdir/$server\n"); + } + my($auth, $host) = split('@', $server); + ($auth, $host) = (':', $auth) if(!$host); + my($user, $pass) = split(':', $auth); + ($host, my $port) = split(':', $host); + $port ||= 119; + print "Connecting to $host:$port with credentials [$user,$pass]\n" if(DEBUG); + my $client = Net::NNTP::Client->new( + "$host:$port", + server => $host, + port => $port, + (($user) ? (user => $user, pass => $pass) : ()), + debug => 0, # set to 1 by default - hate! + ); + # refresh groups list if this is a new server or the list is more + # than 7 days old + if(!-f "$confdir/groups.$server" || -M "$confdir/groups.$server" > 7) { + my $list = eval { $client->list() }; + if($@) { + print STDERR "$@\n"; + next SERVERS; + } + open(FILE, ">$confdir/groups.$server") || die("Can't write $confdir/groups.$server\n"); + print FILE "$_\n" foreach(sort keys %{$list}); + close(FILE); + print "Updated groups list, see $confdir/groups.$server\n"; + } + + GROUPS: foreach my $group (keys %{$subscriptions->{$server}}) { + my($articles, $firstarticle) = eval { $client->group($group); }; + if($@) { + print STDERR "$@\n"; + next SERVERS; + } + if(!-e "$confdir/$server/$group.lastretrieved") { + # new subscription, so set lastretrieved to current + open(FOO, ">$confdir/$server/$group.lastretrieved") || + die("Can't write $confdir/$server/$group.lastretrieved\n"); + print FOO $firstarticle + $articles - 1; + close(FOO); + print "New subscription: $server/$group\n first: $firstarticle\n articles: $articles\n" if(DEBUG); + next GROUPS; + } + open(FOO, "$confdir/$server/$group.lastretrieved") || + die("Can't read $confdir/$server/$group.lastretrieved\n"); + chomp(my $lastretrieved = ); + $client->nntpstat($lastretrieved); + close(FOO); + FETCHNEWS: while(my $msgid = $client->next()) { + if(exists($seen{$msgid})) { # already got this article + print "$group: $msgid already seen\n" if(DEBUG); + $seen{$msgid} = time(); # update timestamp + $lastretrieved++; + open(FOO, ">$confdir/$server/$group.lastretrieved") || + die("Can't write $confdir/$server/$group.lastretrieved\n"); + print FOO $lastretrieved; + close(FOO); + next FETCHNEWS; + } + my $article = [map { chomp; $_; } @{$client->head($msgid)}]; + # filter based on headers here + push @{$article}, '', map { chomp; $_; } @{$client->body($msgid)}; + + print "$group: fetched $msgid\n" if(DEBUG); + + my @newsheaders; + my @headers = ( + "To: $address", + "Reply-To: ". + ($subscriptions->{$server}->{$group}->{post} || 'dave.null'), + "X-Newsgroup: $group" + ); + while((my $line = shift(@{$article})) ne '') { + if($line =~ /^\s+/) { $newsheaders[-1] .= $line; } + else { push @newsheaders, $line; } + } + foreach my $line (@newsheaders) { + if($line =~ /^(Message-Id|Date|Subject|From)/i) { + # headers common to mail and news + push @headers, $line; + } elsif($line =~ /^Path: (.*)$/i) { + push @headers, "Received: from $host with NNTP path $1"; + } elsif($line =~ /^References: (.*)$/i) { + my @refs = split(/\s+/, $1); + push @headers, $line, "In-Reply-To: $refs[-1]"; + } else { + push @headers, "X-NNTP-Header-$line"; + } + } + + my $body = $article; + + my $sender = Email::Send->new({mail => 'SMTP'}); + $sender->mailer_args([Host => $smtphost]); + $sender->send( + join("\n\n", + join("\n", sort { $a cmp $b } @headers), + join("\n", @{$body}) + ) + ); + + $seen{$msgid} = time(); # so we never fetch this one again + $lastretrieved++; + open(FOO, ">$confdir/$server/$group.lastretrieved") || + die("Can't write $confdir/$server/$group.lastretrieved\n"); + print FOO $lastretrieved; + close(FOO); + } + } +} + +# while(my($msgid, $time) = each(%seen)) { +# if(time() - $time > 2 * 86400) { +# delete $seen{$msgid}; +# } +# } + +# now optimise seendb +# delete anything from 'seen' more than a year old. This is partially for +# dropping cross-posts, (we use lastretrieved to avoid going back in time) +# but also for when a server shits its pants +my %newseen; +$newseen{$_} = $seen{$_} foreach( + grep { time() - $seen{$_} < 365 * 86400 } keys %seen +); +untie %seen; +unlink "$confdir/seen.dbm"; +tie %seen, 'GDBM_File', "$confdir/seen.dbm", GDBM_WRCREAT, 0640; +$seen{$_} = $newseen{$_} foreach(keys %newseen); +untie %seen; diff --git a/examples/drhyde-news2mail-and-mail2news/yapc-europe-2007-paper.pdf b/examples/drhyde-news2mail-and-mail2news/yapc-europe-2007-paper.pdf new file mode 100644 index 0000000..f3bee99 Binary files /dev/null and b/examples/drhyde-news2mail-and-mail2news/yapc-europe-2007-paper.pdf differ diff --git a/examples/drhyde-news2mail-and-mail2news/yapc-europe-2007-paper.pod b/examples/drhyde-news2mail-and-mail2news/yapc-europe-2007-paper.pod new file mode 100644 index 0000000..fb65679 --- /dev/null +++ b/examples/drhyde-news2mail-and-mail2news/yapc-europe-2007-paper.pod @@ -0,0 +1,177 @@ +=head1 news2mail and mail2news - a Usenet/Email gateway + +=head2 Abstract + +Usenet has a bad reputation for being full of spam and idiots, but this is no longer really justified. Most of the spam is dealt with by automatic cancelbots before normal people ever get to see it, and the current crop of idiots don't know about Usenet anyway because as far as they're concerned, if it isn't Teh Web then it doesn't exist. So the only thing that sucks about Usenet these days is the dreadful client software. + +With a good client, Usenet becomes a great place to discuss any topic and make friends. That's why I wrote news2mail and its companion mail2news. They are perl scripts which speak sufficient subsets of NNTP and SMTP to make Usenet available in your mail client and enable posting to Usenet as if it were a mailing list. + +=head2 Where to get the software + +L + +=head2 Other implementations + +There are *lots* of other implementations of this idea. However, all the ones I looked at when I needed it had one big flaw - they assumed that you were running your own local news server and so could read and write messages directly from and to the news spool. Worse, many of them assumed that you were running INN. I not only don't run my own news server, but if I did, INN would be a serious case of overkill for my own personal use. + +So I did what any hacker would do, and wrote my own version. + +=head2 Message formats + +These two scripts are, effectively, a bit of glue sticking two different protocols together. Both SMTP and NNTP are concerned with transferring text messages from one place to another, and the message formats are nigh-on identical. Here's a typical email, which I received from a mailing list: + + Return-path: + Envelope-to: david@cantrell.org.uk + Delivery-date: Fri, 17 Aug 2007 14:15:32 +0100 + Received: from dewey.classiccmp.org ([209.145.140.57]) + by bytemark.barnyard.co.uk with esmtp (Exim 3.35 #1) + id 1IM1fo-0006tf-00 + for david@cantrell.org.uk; Fri, 17 Aug 2007 14:15:32 +0100 + [ several other Received headers cut out ] + Date: Fri, 17 Aug 2007 11:23:04 +0100 + From: David Cantrell + To: "General Discussion: On-Topic Posts Only" + Message-ID: <20070817102303.GA31679@bytemark.barnyard.co.uk> + X-Sepdate: Fri Sep 5099 10:27:25 BST 1993 + References: <200708140955.50011.mark@wickensonline.co.uk> + Mime-Version: 1.0 + Content-Type: text/plain; charset=us-ascii + Content-Disposition: inline + In-Reply-To: <200708140955.50011.mark@wickensonline.co.uk> + User-Agent: Mutt/1.5.9i + Subject: Re: UK retro show evening + Precedence: list + Reply-To: "General Discussion: On-Topic Posts Only" + Sender: cctech-bounces@classiccmp.org + + On Tue, Aug 14, 2007 at 09:55:49AM +0100, Mark Wickens wrote: + + > I'm thinking 'start small' here. Maybe an event with 30 or so + > participants? Primarily to 'chew-the-cud'? + + How about "come to the pub and natter". + I propose the evening of Thursday the 6th of September, at whatever + venue the London Perl Mongers choose for their social ... + +and here's a typical Usenet posting: + + Path: g2news2.google.com!postnews.google.com!... + From: roberthar...@my-deja.com + Newsgroups: alt.2eggs.sausage.beans.tomatoes.2toast.largetea.cheerslove + Subject: Re: black Pudding + Date: Wed, 22 Aug 2007 17:15:13 -0700 + Organization: http://groups.google.com + Lines: 20 + Message-ID: <1187828113.562214.100540@m37g2000prh.googlegroups.com> + References: <46CC4CFA.2A57EE2B@yahoo.com> + NNTP-Posting-Host: 195.137.63.170 + Mime-Version: 1.0 + Content-Type: text/plain; charset="us-ascii" + X-Complaints-To: groups-abuse@google.com + NNTP-Posting-Date: Thu, 23 Aug 2007 00:15:14 +0000 (UTC) + In-Reply-To: <46CC4CFA.2A57EE2B@yahoo.com> + User-Agent: G2/1.0 + X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20061201 Firefox/2.0.0.6 (Ubuntu-feisty),gzip(gfe),gzip(gfe) + + On 22 Aug, 15:49, Reverend Hoovie wrote: + + > Did a google on black pudding and must admit it sounds quite tasty. + + I love black pudding, except as served in hotel help-yersel buffets. + ... + +Both are basically the same format with just a few very minor changes. Both have From, Date, Subject and Message-ID headers, for example. The email's To header is replaced with usenet's Newsgroups header, and email uses multiple Received headers to show how a message got to you where Usenet instead uses a single Path header. + +This makes the task of translating between the two systems very easy. + +=head2 From Usenet to email + +The news2mail script is designed to be run periodically from a cron job, and to store all its configuration and state information under your home directory. It uses Net::NNTP::Client to talk to any number of news servers, retrieving different newsgroups from each one - this means that you can use it to retrieve public postings from public servers, as well as private groups run by your university or company. + +For each message that it retrieves it does a few simple edits to the headers before using Email::Send to forward it to whatever address you choose using SMTP. Those edits are: + +=over + +=item Insert a To header + +=item Insert a Reply-To header + +This will be either the address that you have configured for the mail2news script to use for posting, or if you've not configured posting to the group that this message came from it will be 'dave.null'. + +=item Insert an X-Newsgroup header + +So that you can see where it came from, and more importantly so that procmail can see it as well and filter your mail into folders. + +=item Path is translated to Received + +The Path header is turned into "Received: from [hostname] with NNTP path ..." which is not strictly legal, but it works. Google do something similarly illegal with Received headers emited by gmail, so I reckon I'm in good company. + +=item References header is turned into In-Reply-To + +Although you do see emails with References headers, In-Reply-To seems to be more widely implemented. + +=back + +Date, Message-Id, Subject and From are passed through unchanged, and anything else is turned into an X-NNTP-Header-$foo header. + +The message is then passed to Email::Send, and ends up in your mailbox. It then updates a cache of message-ids that it has seen, in case a server burps and re-sends stuff (which happens occasionally, and also eliminates cross-posts) and goes on to the next message. + +Finally, anything that's been in the cache for more than a year is deleted. + +=head2 From Email to Usenet + +Going in the opposite direction, from email to Usenet, is just as simple. The mail2news script is meant to be invoked by the mail server, and is handed an email on STDIN, with the newsgroup name on the command line. Again, a few headers are edited - we add a Newsgroups header so that the news server will know which group we're posting to, drop the Date, To and Received headers, and then insert a Date header again. The shenanigans with dropping and then adding a date header are to work around a problem with some mail clients setting incorrectly formatted dates, which then confuse the news server. + +It reads a configuration file which tells it which servers to use for posting to which groups, and logs in to each appropriate server in turn, using a username and password if necessary. Provided that the server confirms that yes, you can post to it, the article is sent on its way. + +=head2 Configuration + +=head3 news2mail + +news2mail looks in $HOME/.news2mail for several items. The most important of those is config.pl, which looks like this: + + 'username:password@server.example.com:portnumber' => { + 'comp.lang.perl.misc' => + { post => 'clpm-post@example.com' }, + 'alt.2eggs.sausage.beans.tomatoes.2toast.largetea.cheerslove' => + { post => '2eggs-post@example.com' } + }, + 'news.somewhereelse.wherever' => { + 'local.fart-jokes' => { post => 0 } + } + +which is a simple hash where keys are servers to query. Their associated values are hashes whose keys are group names. *Their* values are again hashes, which currently have a single key 'post' whose value is either 0, meaning that you can't post, or the email address for sending articles to the group. + +The other items in that directory will be created by news2mail, and are the cache of previously seen message-ids, and the number of the last message we saw in each group, which makes startup next time quicker. If that number doesn't exist (ie we've just subscribed to a group) then it is set to the last message in the group, to avoid downloading *everything* the first time. You really don't want to do that, as some servers store several hundred days worth of messages and your mail server wouldn't like that. + +=head3 mail2news + +Configuring mail2news is a bit more complicated. First, you'll need to create a /etc/mail2newsrc file like this: + + 'username:password@server.example.com:portnumber' => { + 'comp.lang.perl.misc' => 1, + 'alt.2eggs.sausage.beans.tomatoes.2toast.largetea.cheerslove' => 1 + } + +which lists all the servers that we can post to, and for each of them the groups that we can post to. Note that this applies to all mail2news users on this system. + +Then you will need to configure your mail server to accept mail for the appropriate addresses, and tell it what to do with 'em. The easiest way is to drop some entries in the /etc/aliases file: + + clpm-post: "|/usr/local/bin/mail2news comp.lang.perl.misc" + 2eggs-post: "|/usr/local/bin/mail2news alt.2eggs.sausage.beans.tomatoes.2toast.largetea.cheerslove" + +This is too complicated and has a couple of nasty little security holes on a multi-user system, but I wrote the software for my own use where they're not an issue. + +=head2 How to contribute + +I have created a mailing list to which I invite anyone interested in using or hacking on the scripts to subscribe. It is Edrhyde-news2mail@lists.sourceforge.netE and is managed using mailman. You can subscribe at L. + +=head1 AUTHOR, COPYRIGHT and LICENCE + +Copyright 2007 David Cantrell Edavid@cantrell.org.ukE + +The news2mail and mail2news scripts are licenced under the same terms as perl itself. + +This documentation may be used and distributed by anyone but may not be modified without permission from the author. + +=cut -- cgit