#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
# <jesse@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301 or visit their web page on the internet at
-# http://www.gnu.org/copyleft/gpl.html.
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# CONTRIBUTION SUBMISSION POLICY:
use RT::EmailParser;
use Mail::Address;
-use Date::Format qw(strftime);
=head1 NAME
sub Commit {
my $self = shift;
- my ($ret) = $self->SendMessage( $self->TemplateObj->MIMEObj );
- if ( $ret > 0 ) {
- $self->RecordOutgoingMailTransaction( $self->TemplateObj->MIMEObj )
- if ($RT::RecordOutgoingEmail);
- }
- return (abs $ret);
+ return($self->SendMessage($self->TemplateObj->MIMEObj));
}
# }}}
|| $MIMEObj->head->get('Bcc') )
{
$RT::Logger->info( $msgid . " No recipients found. Not sending.\n" );
- return (-1);
- }
-
- unless ($MIMEObj->head->get('Date')) {
- # We coerce localtime into an array since strftime has a flawed prototype that only accepts
- # a list
- $MIMEObj->head->replace(Date => strftime('%a, %d %b %Y %H:%M:%S %z', @{[localtime()]}));
- }
-
- return (0) unless ($self->OutputMIMEObject($MIMEObj));
-
- my $success = $msgid . " sent ";
- foreach( qw(To Cc Bcc) ) {
- my $recipients = $MIMEObj->head->get($_);
- $success .= " $_: ". $recipients if $recipients;
- }
- $success =~ s/\n//g;
-
- $RT::Logger->info($success);
-
- return (1);
-}
-
-
-=head2 OutputMIMEObject MIME::Entity
-
-Sends C<MIME::Entity> as an email message according to RT's mailer configuration.
-
-=cut
-
-
-
-sub OutputMIMEObject {
- my $self = shift;
- my $MIMEObj = shift;
-
- my $msgid = $MIMEObj->head->get('Message-ID');
- chomp $msgid;
-
- my $SendmailArguments = $RT::SendmailArguments;
- if (defined $RT::VERPPrefix && defined $RT::VERPDomain) {
- my $EnvelopeFrom = $self->TransactionObj->CreatorObj->EmailAddress;
- $EnvelopeFrom =~ s/@/=/g;
- $EnvelopeFrom =~ s/\s//g;
- $SendmailArguments .= " -f ${RT::VERPPrefix}${EnvelopeFrom}\@${RT::VERPDomain}";
+ return (1);
}
local $SIG{'CHLD'} = 'DEFAULT';
my $mail;
- unless( open $mail, "|$RT::SendmailPath $SendmailArguments" ) {
+ unless( open $mail, "|$RT::SendmailPath $RT::SendmailArguments" ) {
die "Couldn't run $RT::SendmailPath: $!";
}
local $ENV{MAILADDRESS};
if ( $RT::MailCommand eq 'sendmail' ) {
- push @mailer_args, split(/\s+/, $SendmailArguments);
+ push @mailer_args, split(/\s+/, $RT::SendmailArguments);
}
elsif ( $RT::MailCommand eq 'smtp' ) {
$ENV{MAILADDRESS} = $RT::SMTPFrom || $MIMEObj->head->get('From');
return (0);
}
}
- return 1;
+
+ my $success = "$msgid sent";
+ foreach (qw(To Cc Bcc)) {
+ next unless my $addresses = $MIMEObj->head->get($_);
+ $success .= " $_: ". $addresses;
+ }
+ $success =~ s/\n//g;
+
+ $self->RecordOutgoingMailTransaction($MIMEObj) if ($RT::RecordOutgoingEmail);
+
+ $RT::Logger->info($success);
+
+ return (1);
}
# }}}
sub RemoveInappropriateRecipients {
my $self = shift;
- my $msgid = $self->TemplateObj->MIMEObj->head->get ('Message-Id');
-
-
-
my @blacklist;
my @types = qw/To Cc Bcc/;
@{ $self->{'Cc'} } = ();
@{ $self->{'Bcc'} } = ();
- $RT::Logger->info( $msgid . " The incoming message was autogenerated. Not redistributing this message based on site configuration.\n");
}
elsif ( $RT::RedistributeAutoGeneratedMessages eq 'privileged' ) {
}
}
- $RT::Logger->info( $msgid . " The incoming message was autogenerated. Not redistributing this message to unprivileged users based on site configuration.\n");
}
unless ( $self->TemplateObj->MIMEObj->head->get('From') ) {
if ($RT::UseFriendlyFromLine) {
- my $friendly_name = $self->TransactionObj->CreatorObj->RealName
- || $self->TransactionObj->CreatorObj->Name;
+ my $friendly_name = $self->TransactionObj->CreatorObj->RealName;
if ( $friendly_name =~ /^"(.*)"$/ ) { # a quoted string
$friendly_name = $1;
}
sub SetSubjectToken {
my $self = shift;
+ my $tag = "[$RT::rtname #" . $self->TicketObj->id . "]";
my $sub = $self->TemplateObj->MIMEObj->head->get('Subject');
- my $id = $self->TicketObj->id;
-
- my $token_re = $RT::EmailSubjectTagRegex;
- $token_re = qr/\Q$RT::rtname\E/o unless $token_re;
- return if $sub =~ /\[$token_re\s+#$id\]/;
-
- $sub =~ s/(\r\n|\n|\s)/ /gi;
- chomp $sub;
- $self->TemplateObj->MIMEObj->head->replace(
- Subject => "[$RT::rtname #$id] $sub",
- );
+ unless ( $sub =~ /\Q$tag\E/ ) {
+ $sub =~ s/(\r\n|\n|\s)/ /gi;
+ chomp $sub;
+ $self->TemplateObj->MIMEObj->head->replace( 'Subject', "$tag $sub" );
+ }
}
# }}}