procmail
[Top] [All Lists]

Re: fortune mode with procmail

2007-03-28 16:06:03
On Wed, Mar 28, 2007 at 01:18:37PM +0200,
bernard(_dot_)schoenacker(_at_)free(_dot_)fr wrote:

Selon Dallman Ross <dman(_at_)nomotek(_dot_)com>:

On Tue, Mar 27, 2007 at 05:22:17AM +0200,
bernard(_dot_)schoenacker(_at_)free(_dot_)fr wrote:

I already have some examples of models with automatic
response, but she can read  only the complete text ...

howto use and adapt the response by courtesy when become
a bad attachment of a foreing language ?

What is it you aren't able to do, exactly?  You say you have
some examples already.  (There is one in the procmailex man
page, for example, in the extended "vacation" recipe.)
What doesn't work?  Can you show some procmail code that
you're stuck with?

   :0
   * condition(s)
   * ! ^X-Loop: your(_at_)own(_dot_)mail(_dot_)address
   | (formail -r -k \
              -I "Precedence: junk" \
              -A "X-Loop: your(_at_)own(_dot_)mail(_dot_)address" ; \
          cat /path/to/message ) | $SENDMAIL -t

Pretty much right out of "man procmailex", though I added a sample
condition, added the -k flag to formail to quote the incoming body,
and changed 'echo "some message"' to 'cat path/to/mesage'.

for me it would be an interesting solution, owing to the fact
that it is possible to make read an extract of the text ...

but with your syntax : " cat message " i become de full text and
not a extract and adapted to the language of the recipient


the answer for wrong attachment contain document in :
               - English
               - French
               - German


Bernard,

You would set up a series of messages in different languages.
You would set your conditions on the recipe to detect the
language.  While there are various ways to do it, the simplest
to get going is probably one recipe per language.

Do you know how to set up a sandbox and test your code?  See
the .sig line of frequent poster Sean Straw here for the link
to his pages describing how he does that and you you can adopt
his method.  If you are going to try various reasonably advanced
things in procmail, you need to be able to test your code
interactively before putting it in production.

The MIME headers sometimes give away the language, but not
always.  You might need to test for common words to decide
if a message is in German, French, English, or whatever.
Also, if you are looking at attachments or at MIME-encoded
text, then the problem is more complicated.

Can't you just have a response that has three langauges?

  Your mail has arrived in a language the recipient is
  not prepared to read.  It is therefore being bounced
  back to you unread.

  Ihre Nachricht erscheint in einer Sprache, die der
  Empfanger nicht bereit zu lesen ist.  Die Nachricht
  wird deshalb an Sie zurueckgebounct, onhe, dass
  sie gelesen wurde.

  [Fill in the French yourself.]


If you don't like the three-languages-in-one-message approach,
you'll have to decide some way to find the langauge the message
is in.  Assuming ASCII in the body of the message, something
like this might work to find German.

   :0 B  # body egrep except for the 1st condition, explicitly excepted
   * H ?? ! ^X-Loop: your(_at_)own(_dot_)mail(_dot_)address
   *   1^0 ()\<(der|den|dem|des|die|das|denen)\>
   *   1^0 ()\<[dms]?(ein|einer|eine|einen|eine?s|einem)\>
   *   1^0 ()\<(ihr|ihre|ihrer|ihres|ihren|ihrem
   *   1^0 ()\<(dies(e[mnrs]?)?|jen(e[mnrs]?)?)\>
   * -10^0
   [. . . .]

The first condition could also be written, e.g.,

   * 1^0 \<(d(e[rnms]|nen)|ie|as)\>

I haven't actually tested it to double-check my regex, though.  In
fact, that's true on all of these.  Anyway, it might be better not
to get so fancy/overly cute here.

Anyway, that requires more than 10 hits on those in the text.
Then we'd decide it's probably German.

Then you add the rest of the recipe as shown, where
"message.de" is the German message.

   | (formail -r -k \
              -I "Precedence: junk" \
              -A "X-Loop: your(_at_)own(_dot_)mail(_dot_)address" ; \
           cat /path/to/message.de ) | $SENDMAIL -t


Dallman

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>