[Rt-commit] r6719 - in rt/branches/3.7-EXPERIMENTAL: .
ruz at bestpractical.com
ruz at bestpractical.com
Tue Jan 9 15:53:34 EST 2007
Author: ruz
Date: Tue Jan 9 15:53:33 2007
New Revision: 6719
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Email.pm
Log:
r4291 at cubic-pc: cubic | 2006-12-13 02:14:44 +0300
* drop # {{{|}}} comments
* drop trailing spaces
* add descriptions for methods
Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Email.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Email.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Email.pm Tue Jan 9 15:53:33 2007
@@ -102,9 +102,12 @@
=head1 METHODS
-=cut
+=head2 CheckForLoops HEAD
+
+Returns true if the message's been sent by this RT instance.
+Uses "X-RT-Loop-Prevention" field of the head for that.
-# {{{ sub CheckForLoops
+=cut
sub CheckForLoops {
my $head = shift;
@@ -121,9 +124,13 @@
return undef;
}
-# }}}
+=head2 CheckForSuspiciousSender HEAD
+
+Returns true if sender is suspicious. Suspicious means mailer daemon.
-# {{{ sub CheckForSuspiciousSender
+See also L</ParseSenderAddressFromHead>.
+
+=cut
sub CheckForSuspiciousSender {
my $head = shift;
@@ -147,9 +154,13 @@
return undef;
}
-# }}}
+=head2 CheckForAutoGenerated HEAD
+
+Returns true if message is autogenerated. Checks 'Precedence'
+and 'X-FC-Machinegenerated' fields of the head.
+
+=cut
-# {{{ sub CheckForAutoGenerated
sub CheckForAutoGenerated {
my $head = shift;
@@ -167,9 +178,7 @@
return (0);
}
-# }}}
-# {{{ sub CheckForBounce
sub CheckForBounce {
my $head = shift;
@@ -177,13 +186,11 @@
return ( $ReturnPath =~ /<>/ );
}
-# }}}
-# {{{ IsRTAddress
=head2 IsRTAddress ADDRESS
-Takes a single parameter, an email address.
+Takes a single parameter, an email address.
Returns true if that address matches the C<RTAddressRegexp> config option.
Returns false, otherwise.
@@ -201,9 +208,7 @@
return undef;
}
-# }}}
-# {{{ CullRTAddresses
=head2 CullRTAddresses ARRAY
@@ -216,9 +221,35 @@
return ( grep { IsRTAddress($_) } @_ );
}
-# }}}
+=head2 MailError PARAM HASH
+
+Sends an error message. Takes a param hash:
+
+=over 4
+
+=item From - sender's address, by default is 'CorrespondAddress';
+
+=item To - reciepient, by default is 'OwnerEmail';
+
+=item Bcc - optional Bcc recipients;
+
+=item Subject - subject of the message, default is 'There has been an error';
+
+=item Explanation - main content of the error, default value is 'Unexplained error';
+
+=item MIMEObj - optional MIME entity that's attached to the error mail, as well we
+add 'In-Reply-To' field to the error that points to this message.
+
+=item Attach - optional text that attached to the error as 'message/rfc822' part.
+
+=item LogLevel - log level under which we should write explanation message into the
+log, by default we log it as critical.
+
+=back
+
+
+=cut
-# {{{ sub MailError
sub MailError {
my %args = (
To => RT->Config->Get('OwnerEmail'),
@@ -235,7 +266,7 @@
$RT::Logger->log(
level => $args{'LogLevel'},
message => $args{'Explanation'}
- );
+ ) if $args{'LogLevel'};
my $entity = MIME::Entity->build(
Type => "multipart/mixed",
From => $args{'From'},
@@ -249,10 +280,9 @@
$entity->attach( Data => $args{'Explanation'} . "\n" );
- my $mimeobj = $args{'MIMEObj'};
- if ($mimeobj) {
- $mimeobj->sync_headers();
- $entity->add_part($mimeobj);
+ if ( $args{'MIMEObj'} ) {
+ $args{'MIMEObj'}->sync_headers;
+ $entity->add_part( $args{'MIMEObj'} );
}
if ( $args{'Attach'} ) {
@@ -263,7 +293,6 @@
SendEmail(entity => $entity, bounce => 1);
}
-# {{{ SendEmail
=head2 SendEmail entity => ENTITY, [bounce => BOUNCE]
@@ -304,7 +333,7 @@
# VERP
if ( $args{'transaction'} and
- my $prefix = RT->Config->Get('VERPPrefix') and
+ my $prefix = RT->Config->Get('VERPPrefix') and
my $domain = RT->Config->Get('VERPDomain') )
{
my $from = $args{'transaction'}->CreatorObj->EmailAddress;
@@ -362,9 +391,7 @@
return 1;
}
-# }}}
-# {{{ Create User
sub CreateUser {
my ( $Username, $Address, $Name, $ErrorsTo, $entity ) = @_;
@@ -424,15 +451,13 @@
return $CurrentUser;
}
-# }}}
-# {{{ ParseCcAddressesFromHead
-=head2 ParseCcAddressesFromHead HASHREF
+=head2 ParseCcAddressesFromHead HASH
-Takes a hashref object containing QueueObj, Head and CurrentUser objects.
-Returns a list of all email addresses in the To and Cc
-headers b<except> the current Queue\'s email addresses, the CurrentUser\'s
+Takes a hash containing QueueObj, Head and CurrentUser objects.
+Returns a list of all email addresses in the To and Cc
+headers b<except> the current Queue\'s email addresses, the CurrentUser\'s
email address and anything that the configuration sub RT::IsRTAddress matches.
=cut
@@ -464,13 +489,11 @@
return (@Addresses);
}
-# }}}
-# {{{ ParseSenderAdddressFromHead
-=head2 ParseSenderAddressFromHead
+=head2 ParseSenderAddressFromHead HEAD
-Takes a MIME::Header object. Returns a tuple: (user at host, friendly name)
+Takes a MIME::Header object. Returns a tuple: (user at host, friendly name)
of the From (evaluated in order of Reply-To:, From:, Sender)
=cut
@@ -485,11 +508,9 @@
return ( ParseAddressFromHeader($From) );
}
-# }}}
-# {{{ ParseErrorsToAdddressFromHead
-=head2 ParseErrorsToAddressFromHead
+=head2 ParseErrorsToAddressFromHead HEAD
Takes a MIME::Header object. Return a single value : user at host
of the From (evaluated in order of Return-path:,Errors-To:,Reply-To:,
@@ -515,13 +536,11 @@
}
}
-# }}}
-# {{{ ParseAddressFromHeader
=head2 ParseAddressFromHeader ADDRESS
-Takes an address from $head->get('Line') and returns a tuple: user at host, friendly name
+Takes an address from C<$head->get('Line')> and returns a tuple: user at host, friendly name
=cut
@@ -529,7 +548,7 @@
my $Addr = shift;
# Some broken mailers send: ""Vincent, Jesse"" <jesse at fsck.com>. Hate
- $Addr =~ s/\"\"(.*?)\"\"/\"$1\"/g;
+ $Addr =~ s/\"\"(.*?)\"\"/\"$1\"/g;
my @Addresses = Mail::Address->parse($Addr);
my $AddrObj = $Addresses[0];
@@ -546,9 +565,7 @@
return ( $Address, $Name );
}
-# }}}
-# {{{ sub ParseTicketId
sub ParseTicketId {
my $Subject = shift;
@@ -566,7 +583,6 @@
}
}
-# }}}
=head2 Gateway ARGSREF
@@ -588,16 +604,16 @@
Returns:
An array of:
-
+
(status code, message, optional ticket object)
status code is a numeric value.
for temporary failures, the status code should be -75
- for permanent failures which are handled by RT, the status code
+ for permanent failures which are handled by RT, the status code
should be 0
-
+
for succces, the status code should be 1
@@ -782,7 +798,7 @@
unless ($continue) {
return ( 0, $result, undef );
}
-
+
# strip actions we should skip
@actions = grep !$skip_action{$_}, @actions;
@@ -990,7 +1006,7 @@
my $IsALoop = CheckForLoops($head);
my $SquelchReplies = 0;
-
+
my $owner_mail = RT->Config->Get('OwnerEmail');
#If the message is autogenerated, we need to know, so we can not
More information about the Rt-commit
mailing list