1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
# pm-jafrom.rc -- get message's best FROM field without calling `formail'
#
# File id
#
# Copyright (C) 1997-2010 Jari Aalto
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details at
# <http://www.gnu.org/copyleft/gpl.html>.
#
# Description
#
# This includerc extracts the most likely FROM address from the
# message. The order of the search is Reply-to, From_, Sender, From
# and if none found, then as a last resort, call `formail'. You would
# usually use the returned value for logging purposes.
#
# Avoiding extra formail call could be usefull if you receive lot
# of messages per day.
#
# Example input
#
# (none)
#
# Returned values
#
# OUTPUT, containing the derived FROM field
#
# Required settings
#
# PMSRC must point to source directory of procmail code. This subroutine
# will include pm-javar.rc from there. You nee procmail 3.11pre7 in
# order to use this subroutine. (due to formail -z switch)
#
# Call arguments (variables to set before calling)
#
# (none)
#
# Usage example
#
# INCLUDERC = $PMSRC/pm-jafrom.rc
# FROM = $OUTPUT # now we have the 'best' FROM field
#
# Change Log (none)
# .................................................... &initialising ...
id = "pm-jafrom.rc"
dummy = "
========================================================================
$id: init:
"
:0
* ! WSPC ?? [ ]
{
INCLUDERC = $PMSRC/pm-javar.rc
}
# ..................................................... &output-vars ...
# output variables
OUTPUT
# ........................................................... &do-it ...
# Check that input is something like: Thu, 13 Nov 1997
dummy = "$id: Get message's FROM field."
:0
*$ ! ^Reply-to: *\/$NSPC.*
*$ ! ^From: *\/$NSPC.*
*$ ! ^Sender: *\/$NSPC.*
*$ ! ^From *\/$NSPC+
{
OUTPUT = `formail -zxFrom:`
}
:0 E
{
OUTPUT = $MATCH
}
dummy = "$id: end:"
# end of file pm-jafrom.rc
|