[thelist] Email news to a website

Steve Lewis slewis at macrovista.net
Thu May 16 15:29:01 CDT 2002


Michael Galvin wrote:

>Is there any freely-available perl script that would allow a user to email a
>piece of news to a certain email address, and the script would automatically
>parse the mail and 'post' it to a news page on the server?
>
>I can't see any way of doing it without using a CRON job and a lot of sticky
>Perl scripting to work out headers, and stuff it all into a template.  I'm
>no Perl expert (even what I just wrote makes little sense to me :) so any
>help would be appareciated.
>
>
Solution 1)
In this case, use a .qmail file (man dot-qmail) or a .forward file to
fire your Perl script at the time of message receipt (no cron necessary)
with the message available.

you will use the | (pipe) in this file to indicate you want to fire a
script, that is you might use:

| /home/myuser/bin/postnews.pl

as your .forward file or .qmail

Now don't cringe, it isn't sticky Perl scripting... search for the first
blank line, discard it and everything that comes before it.  When you
examine you raw emails you will notice the headers are always separated
from the body of the message by one blank line.   (RFC 822)

 From here you have the body of the message queued up in $1, you perform
the necessary markup and write out the new news file on the server...
how you link to it is up to you.  This entire solution can be coded
right out of The Camel Book without really groking anything about
Perl... I know because I did this back in 1996 or so when I was first
playing with dynamic content and I didn't have a clue about Perl.  This
should work for you pretty easily if I have not lost my memory.

Solution 2)
You have procmail available you say?  Holy Cow! This just got REAL easy.
First we create a procmail recipe to catch the email message bodys and
pass them to the Perl script:

:0 b: .proclock
* ^From: authorizednewsposter at sample.org
| /home/myuser/bin/postnews.pl

Now you are in your Perl script, you have the body of the message queued
up in $1 and you just apply your formatting and write out the contents.
 Jiffy.

--Steve




More information about the thelist mailing list