[Rt-commit] r5923 - in rt/branches/3.7-EXPERIMENTAL: .
ruz at bestpractical.com
ruz at bestpractical.com
Tue Sep 12 21:58:51 EDT 2006
Author: ruz
Date: Tue Sep 12 21:58:51 2006
New Revision: 5923
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/bin/rt-mailgate.in
Log:
r3728 at cubic-pc: cubic | 2006-09-13 06:08:33 +0400
rt-mailgate
* add value of $ENV{EXTENSION} to message header
in the 'X-RT-Mail-Extension' field.
Modified: rt/branches/3.7-EXPERIMENTAL/bin/rt-mailgate.in
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/bin/rt-mailgate.in (original)
+++ rt/branches/3.7-EXPERIMENTAL/bin/rt-mailgate.in Tue Sep 12 21:58:51 2006
@@ -69,7 +69,7 @@
}
unless ( $opts{'url'} ) {
- print STDERR "$0 invoked improperly\n\nNo $_ provided to mail gateway!\n";
+ print STDERR "$0 invoked improperly\n\nNo 'url' provided to mail gateway!\n";
exit 1;
}
@@ -84,7 +84,6 @@
# Read the message in from STDIN
$args{'message'} = do { local (@ARGV, $/); <> };
-
unless ( $args{message} =~ /\S/ ) {
print STDERR "$0: no message passed on STDIN!\n";
exit 0;
@@ -98,6 +97,18 @@
$args{ lc $opts{'extension'} } = $ENV{'EXTENSION'};
}
+# add ENV{'EXTENSION'} as X-RT-MailExtension to the message header
+if ( exists $ENV{'EXTENSION'} and my $value = $ENV{'EXTENSION'} ) {
+ # prepare value to avoid MIME format brakage
+ # strip trailing newline symbols
+ $value =~ s/(\r*\n)+$//;
+ # make a correct multiline header field,
+ # with tabs in the beginning of each line
+ $value =~ s/(\r*\n)/\t$1/g;
+ $args{'message'} = "X-RT-Mail-Extension: $value\n"
+ . $args{'message'};
+}
+
# Set up cookie here.
my $full_url = $opts{'url'}. "/REST/1.0/NoAuth/mail-gateway";
@@ -321,5 +332,22 @@
Additionally, if C<-1> is returned, then the processing of the plug-ins
stops immediately and the message is ignored.
+=head1 ENVIRONMENT
+
+=over 4
+
+=item EXTENSION
+
+Some MTAs will route mail sent to user-foo at host or user+foo at host to user at host
+and present "foo" in the environment variable C<EXTENSION>. Mailgate adds value
+of this variable to message in the C<X-RT-Mail-Extension> field of the message
+header.
+
+See also C<--extension> option. Note that value of the environment variable is
+always added to the message header when it's not empty even if C<--extension>
+option is not provided.
+
+=back 4
+
=cut
More information about the Rt-commit
mailing list