OT: help conditioning on multiple fields using procmail

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ranjan Maitra writes:

 > So, I use in my .procmailrc:
 > 
 > :0:
 > *^From.*user@xxxxxxxxxxx
 > $HOME/Mail/sent/.
 > 
 > And it used to work fine. However, recently I have also started
 > forwarding my e-mail from the address: user@xxxxxxxxxxx and what is
 > happening is that the e-mail envelope of every forwarded message
 > now contains the header: Resent-From.*user@xxxxxxxxxxx so all
 > forwarded e-mail is being saved to the sent folder.

Based on your report, one possibility is that your recipe is catching
the "Unix From" line (also called "envelope From line"), which has the
form

>From <optional stuff> user@xxxxxxxxxxxx <optional stuff>

and is prepended to emails saved in so-called mbox format.  (This is
not part of the RFC 5322 Internet Message Format.  It is specific to
the way mail is handled locally by *some* configurations of *some*
message delivery agents.  It is not normally displayed by mail
clients.)  If this is the case, changing the recipe to

:0:
*^From:.*user@xxxxxxxxxxx
$HOME/Mail/sent/.

(change is colon after From) should catch only messages with an RFC
5322 From "user@xxxxxxxxxxx".

 > Is it possible to haveh a double condition? That is something that
 > says that if both Resent-From and From have *user@xxxxxxxxxxx, then
 > it should go to the sent-folder. In other words, is it possible to
 > use a AND or OR or Negation condition.

I'll answer the question, but first I gotta preach. ;-)  When you
don't understand the problem, it is bad practice to ask questions in
the form "how do I do ...", because respondents are likely to focus on
the how of doing what you specifically asked, not on solving your
problem.  That's OK in some sense, you'll learn something, but it's
likely to be frustrating when you do what you're told and it doesn't
solve the underlying problem.

You also should always check the man pages before posting.  Some man
pages are horribly technical (or just plain horribly written), but
others are not.  If you run into a page that's too much to deal with,
it's OK to give up and just ask for help, but only after one more
task: check the See Also section near the bottom.  Frequently there
are pointers to tutorials or examples.  The procmail and procmailrc
pages are pretty technical (I don't think they're "horrible" given
that mail itself is pretty horrible ;-).  The procmailex page, on the
other hand, has pretty much everything you need for a personal
procmailrc, and it has examples for all of them.  Many are
cut-and-pastable!

To AND conditions:

:0:
* ^From:.*user@xxxxxxxxxxx
* ^Resent-From:.*user@xxxxxxxxxxx
$HOME/Mail/sent/.

and BOTH conditions must match the header of the email.  Order doesn't
matter because conditions don't have side effects.  To OR conditions,
use separate recipes:

:0:
* ^From:.*user@xxxxxxxxxxx
$HOME/Mail/sent/.

:0:
* ^Resent-From:.*user@xxxxxxxxxxx
$HOME/Mail/sent/.

and if either condition matches the header of the mail, the mail will
be saved in $HOME/Mail/sent/. .  Most procmail recipes terminate
processing on match, but some don't, so order can matter (but does not
in this case because there are no side effects and the action is the
same).  To NEGATE a condition, use ! preceding the regular expression:

:0:
* ! ^Resent-From:.*user@xxxxxxxxxxx
$HOME/Mail/sent/.

sending anything NOT Resent-From user@xxxxxxxxxxx to .../sent/.

The recipe that MIGHT do what you want if the colon suggestion doesn't
work:

:0:
* ^From.*user@xxxxxxxxxxx
* ! ^Resent-From.*user@xxxxxxxxxxx
$HOME/Mail/sent/.

(look Ma, no colons!, and the Resent-From condition is negated).

HTH

Steve
XEmacs Project
GNU Mailman Project
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux