[Rt-commit] r4713 - in rt/branches/3.7-EXPERIMENTAL: . etc html/NoAuth/images lib/RT/Action lib/RT/Interface lib/t/regression

alexmv at bestpractical.com alexmv at bestpractical.com
Wed Mar 8 18:24:03 EST 2006


Author: alexmv
Date: Wed Mar  8 18:24:01 2006
New Revision: 4713

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/etc/RT_Config.pm.in
   rt/branches/3.7-EXPERIMENTAL/html/NoAuth/images/bplogo.gif
   rt/branches/3.7-EXPERIMENTAL/html/autohandler
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Action/SendEmail.pm
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Email.pm
   rt/branches/3.7-EXPERIMENTAL/lib/t/regression/04send_email.t

Log:
 r8449 at zoq-fot-pik:  chmrr | 2006-03-08 18:23:32 -0500
  * Doc more options


Modified: rt/branches/3.7-EXPERIMENTAL/etc/RT_Config.pm.in
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/etc/RT_Config.pm.in	(original)
+++ rt/branches/3.7-EXPERIMENTAL/etc/RT_Config.pm.in	Wed Mar  8 18:24:01 2006
@@ -176,52 +176,78 @@
 
 Set($SenderMustExistInExternalDatabase , undef);
 
-# }}}
-
-# {{{ Outgoing mail configuration
-
-# RT is designed such that any mail which already has a ticket-id associated
-# with it will get to the right place automatically.
+# @MailPlugins is a list of auth plugins for L<RT::Interface::Email>
+# to use; see L<rt-mailgate>
 
-# $CorrespondAddress and $CommentAddress are the default addresses
-# that will be listed in From: and Reply-To: headers of correspondence
-# and comment mail tracked by RT, unless overridden by a queue-specific
-# address.
+# $UnsafeEmailCommands, if set to true, enables 'take' and 'resolve'
+# as possible actions via the mail gateway.  As its name implies, this
+# is very unsafe, as it allows email with a forged sender to possibly
+# resolve arbitrary tickets!
 
-Set($CorrespondAddress , 'RT_CorrespondAddressNotSet');
 
-Set($CommentAddress , 'RT_CommentAddressNotSet');
+# }}}
 
-#Sendmail Configuration
+# {{{ Outgoing mail configuration
 
-# $MailCommand defines which method RT will use to try to send mail
-# We know that 'sendmailpipe' works fairly well.
-# If 'sendmailpipe' doesn't work well for you, try 'sendmail'
+# $MailCommand defines which method RT will use to try to send mail.
+# We know that 'sendmailpipe' works fairly well.  If 'sendmailpipe'
+# doesn't work well for you, try 'sendmail'.  Other options are 'smtp'
+# or 'qmail'.
 #
 # Note that you should remove the '-t' from $SendmailArguments
 # if you use 'sendmail' rather than 'sendmailpipe'
 
 Set($MailCommand , 'sendmailpipe');
 
-# $SendmailArguments defines what flags to pass to $Sendmail
-# assuming you picked 'sendmail' or 'sendmailpipe' as the $MailCommand above.
-# If you picked 'sendmailpipe', you MUST add a -t flag to $SendmailArguments
+# {{{ Sendmail Configuration
+# These options only take effect if $MailCommand is 'sendmail' or
+# 'sendmailpipe'
 
+# $SendmailArguments defines what flags to pass to $SendmailPath
+# If you picked 'sendmailpipe', you MUST add a -t flag to $SendmailArguments
 # These options are good for most sendmail wrappers and workalikes
 Set($SendmailArguments , "-oi -t");
+# These arguments are good for sendmail brand sendmail 8 and newer
+#Set($SendmailArguments,"-oi -t -ODeliveryMode=b -OErrorMode=m");
 
 # $SendmailBounceArguments defines what flags to pass to $Sendmail
 # assuming RT needs to send an error (ie. bounce).
-
 Set($SendmailBounceArguments , '-f "<>"');
+# If you selected 'sendmailpipe' above, you MUST specify the path to
+# your sendmail binary in $SendmailPath.
+Set($SendmailPath , "/usr/sbin/sendmail");
 
-# These arguments are good for sendmail brand sendmail 8 and newer
-#Set($SendmailArguments,"-oi -t -ODeliveryMode=b -OErrorMode=m");
+# }}}
 
-# If you selected 'sendmailpipe' above, you MUST specify the path
-# to your sendmail binary in $SendmailPath.
-# !! If you did not # select 'sendmailpipe' above, this has no effect!!
-Set($SendmailPath , "/usr/sbin/sendmail");
+# {{{ SMTP configutation
+# These options only take effect if $MailCommand is 'smtp'
+
+# $SMTPServer should be set to the hostname of the SMTP server to use
+Set($SMTPServer, undef)
+# $SMTPFrom should be set to the 'From' address to use, if not the
+# email's 'From'
+Set($SMTPFrom, undef);
+# $SMTPDebug should be set to true to debug SMTP mail sending
+Set($SMTPDebug, 0);
+# }}}
+
+# {{{ Other mailer configuration
+# @MailParams defines a list of options passed to $MailCommand if it
+# is not 'sendmailpipe', 'sendmail', or 'smtp'
+Set(@MailParams, ());
+# }}}
+
+# RT is designed such that any mail which already has a ticket-id associated
+# with it will get to the right place automatically.
+
+# $CorrespondAddress and $CommentAddress are the default addresses
+# that will be listed in From: and Reply-To: headers of correspondence
+# and comment mail tracked by RT, unless overridden by a queue-specific
+# address.
+
+Set($CorrespondAddress , 'RT_CorrespondAddressNotSet');
+
+Set($CommentAddress , 'RT_CommentAddressNotSet');
 
 # By default, RT sets the outgoing mail's "From:" header to
 # "SenderName via RT".  Setting this option to 0 disables it.
@@ -312,8 +338,8 @@
 # This value actually specifies a directory in share/html/NoAuth/css/
 # from which RT will try to load the file main.css (which should
 # @import any other files the stylesheet needs).  This allows you to
-# easily and cleanly create your own stylesheets to apply to RT.
-
+# easily and cleanly create your own stylesheets to apply to RT.  This
+# option can be overridden by users in their preferences.
 Set($WebDefaultStylesheet, '3.5-default');
 
 # Define the directory name to be used for images in rt web
@@ -349,8 +375,9 @@
 # authentication.
 Set($WebNoAuthRegex, qr{^ (?:/+NoAuth/ | /+REST/\d+\.\d+/NoAuth/) }x );
 
-# For message boxes, set the entry box width, height and what type of wrapping
-# to use.
+# For message boxes, set the entry box width, height and what type of
+# wrapping to use.  These options can be overridden by users in their
+# preferences.
 #
 # Default width: 72, height: 15
 Set($MessageBoxWidth, 72);
@@ -404,6 +431,11 @@
 
 Set($WebExternalAuto , undef);
 
+# $AutoCreate is a custom set of attributes to create the user with,
+# if they are created using $WebExternalAuto
+
+Set($AutoCreate, undef);
+
 # $WebSessionClass is the class you wish to use for managing Sessions.
 # It defaults to use your SQL database, but if you are using MySQL 3.x and
 # plans to use non-ascii Queue names, uncomment and add this line to
@@ -429,13 +461,15 @@
 
 
 # $MaxInlineBody is the maximum attachment size that we want to see
-# inline when viewing a transaction. 
-# RT will inline any text if value is undefined or 0.
+# inline when viewing a transaction.  RT will inline any text if value
+# is undefined or 0.  This option can be overridden by users in their
+# preferences.
 
 Set($MaxInlineBody, 12000);
 
 # By default, RT shows newest transactions at the bottom of the ticket
-# history page, if you want see them at the top set this to '0'.
+# history page, if you want see them at the top set this to '0'.  This
+# option can be overridden by users in their preferences.
 
 Set($OldestTransactionsFirst, '1');
 
@@ -499,9 +533,9 @@
 
 # {{{ RT Date Handling Options
 
-# You can choose date and time format.
-# See "Output formatters" section in perldoc lib/RT/Date.pm
-# for more options.
+# You can choose date and time format.  See "Output formatters"
+# section in perldoc lib/RT/Date.pm for more options.  This option can
+# be overridden by users in their preferences.
 # Some examples:
 #Set($DateTimeFormat, { Fromat => 'ISO', Seconds => 0 });
 #Set($DateTimeFormat, 'RFC2822');
@@ -535,6 +569,18 @@
 # both link transactions to have a scrip run.
 Set($LinkTransactionsRun1Scrip , 1);
 
+# Set $PreviewScripMessages to 1 if the scrips preview on the ticket
+# reply page should include the content of the messages to be sent.
+
+# Set $UseTransactionBatch to 1 to execute transactions in batches,
+# such that a resolve and comment (for example) would happen
+# simultaneously, instead of as two transactions, unaware of each
+# others' existance.
+
+# Set @CustomFieldValuesSources to a list of class names which extend
+# RT::CustomFieldValues::External.  This can be used to pull lists of
+# custom field values from external sources at runtime.
+
 # }}}
 
 
@@ -556,5 +602,12 @@
 
 # }}}
 
+# {{{ Deprecated options
+
+# $AlwaysUseBase64 - Encode blobs as base64 in DB (?)
+# $TicketBaseURI - Base URI to tickets in this system; used when loading (?)
+# $UseCodeTickets - This option is exists for backwards compatibility.  Don't use it.
+
+# }}}
 
 1;

Modified: rt/branches/3.7-EXPERIMENTAL/html/NoAuth/images/bplogo.gif
==============================================================================
Binary files. No diff available.

Modified: rt/branches/3.7-EXPERIMENTAL/html/autohandler
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/autohandler	(original)
+++ rt/branches/3.7-EXPERIMENTAL/html/autohandler	Wed Mar  8 18:24:01 2006
@@ -167,7 +167,7 @@
         unless ( $session{'CurrentUser'}->Id ) {
             delete $session{'CurrentUser'};
             $user = $orig_user;
-            if ( RT->Config->Get('WebExternalOnly') ) {
+            unless ( RT->Config->Get('WebFallbackToInternalAuth') ) {
                 $m->comp('/Elements/Login', %ARGS, 
                          Error=> loc('You are not an authorized user'));
                 $m->abort();

Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Action/SendEmail.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Action/SendEmail.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Action/SendEmail.pm	Wed Mar  8 18:24:01 2006
@@ -55,6 +55,7 @@
 use MIME::Words qw(encode_mimeword);
 
 use RT::EmailParser;
+use RT::Interface::Email;
 use Mail::Address;
 
 =head1 NAME
@@ -249,57 +250,7 @@
         return (1);
     }
 
-
-    if ( RT->Config->Get('MailCommand') eq 'sendmailpipe' ) {
-        my $path = RT->Config->Get('SendmailPath');
-        my $args = RT->Config->Get('SendmailArguments');
-        eval {
-            # don't ignore CHLD signal to get proper exit code
-            local $SIG{'CHLD'} = 'DEFAULT';
-
-            my $mail;
-            unless( open $mail, "|$path $args" ) {
-                die "Couldn't run $path: $!";
-            }
-
-            # if something wrong with $mail->print we will get PIPE signal, handle it
-            local $SIG{'PIPE'} = sub { die "$path closed pipe" };
-            $MIMEObj->print($mail);
-
-            unless ( close $mail ) {
-                die "Close failed: $!" if $!; # system error
-                # sendmail exit statuses mostly errors with data not software
-                # TODO: status parsing: core dump, exit on signal or EX_*
-                $RT::Logger->warning( "$path exitted with status $?" );
-            }
-        };
-        if ($@) {
-            $RT::Logger->crit( $msgid ."Could not send mail: " . $@ );
-            return 0;
-        }
-    }
-    else {
-        my @mailer_args = (RT->Config->Get('MailCommand'));
-
-        local $ENV{MAILADDRESS};
-
-        if ( RT->Config->Get('MailCommand') eq 'sendmail' ) {
-            push @mailer_args, split(/\s+/, RT->Config->Get('SendmailArguments'));
-        }
-        elsif ( RT->Config->Get('MailCommand') eq 'smtp' ) {
-            $ENV{MAILADDRESS} = RT->Config->Get('SMTPFrom') || $MIMEObj->head->get('From');
-            push @mailer_args, ( Server => RT->Config->Get('SMTPServer') );
-            push @mailer_args, ( Debug  => RT->Config->Get('SMTPDebug') );
-        }
-        else {
-            push @mailer_args, RT->Config->Get('MailParams');
-        }
-
-        unless ( $MIMEObj->send(@mailer_args) ) {
-            $RT::Logger->crit( $msgid . "Could not send mail." );
-            return (0);
-        }
-    }
+    return(0) unless RT::Interface::Email::SendEmail( entity => $MIMEObj );
 
     my $success = $msgid . " sent ";
     foreach( qw(To Cc Bcc) ) {

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	Wed Mar  8 18:24:01 2006
@@ -257,15 +257,81 @@
 
     }
 
-    if (RT->Config->Get('MailCommand') eq 'sendmailpipe') {
-        my $cmd = RT->Config->Get('SendmailPath') ." ". RT->Config->Get('SendmailArguments');
-        open (MAIL, "|$cmd") || return(0);
-        print MAIL $entity->as_string;
-        close(MAIL);
+    SendEmail(entity => $entity, bounce => 1);
+}
+
+# {{{ SendEmail
+
+=head2 SendEmail entity => ENTITY, [bounce => BOUNCE]
+
+Sends an email (passed as a L<MIME::Entity> object C<ENTITY>) using
+RT's outgoing mail configuration.  If C<BOUNCE> is passed, and is a
+true value, the message will be marked as an autogenerated error, if
+possible.
+
+=cut
+
+sub SendEmail {
+    my (%args) = (
+                  entity => undef,
+                  bounce => 0,
+                  @_,
+                 );
+
+    if ( RT->Config->Get('MailCommand') eq 'sendmailpipe' ) {
+        my $path = RT->Config->Get('SendmailPath');
+        my $args = RT->Config->Get('SendmailArguments');
+        $args .= RT->Config->Get('SendmailBounceArguments') if $args{bounce};
+        eval {
+            # don't ignore CHLD signal to get proper exit code
+            local $SIG{'CHLD'} = 'DEFAULT';
+
+            my $mail;
+            unless( open $mail, "|$path $args" ) {
+                die "Couldn't run $path: $!";
+            }
+
+            # if something wrong with $mail->print we will get PIPE signal, handle it
+            local $SIG{'PIPE'} = sub { die "$path closed pipe" };
+            $args{entity}->print($mail);
+
+            unless ( close $mail ) {
+                die "Close failed: $!" if $!; # system error
+                # sendmail exit statuses mostly errors with data not software
+                # TODO: status parsing: core dump, exit on signal or EX_*
+                $RT::Logger->warning( "$path exitted with status $?" );
+            }
+        };
+        if ($@) {
+            $RT::Logger->crit( "Could not send mail: " . $@ );
+            return 0;
+        }
     }
     else {
-    	$entity->send(RT->Config->Get('MailCommand'), RT->Config->Get('MailParams'));
+        my @mailer_args = (RT->Config->Get('MailCommand'));
+
+        local $ENV{MAILADDRESS};
+        local $ENV{PERL_MAILERS};
+
+        if ( RT->Config->Get('MailCommand') eq 'sendmail' ) {
+            $ENV{PERL_MAILERS} = RT->Config->Get('SendmailPath');
+            push @mailer_args, split(/\s+/, RT->Config->Get('SendmailArguments'));
+        }
+        elsif ( RT->Config->Get('MailCommand') eq 'smtp' ) {
+            $ENV{MAILADDRESS} = RT->Config->Get('SMTPFrom') || $args{entity}->head->get('From');
+            push @mailer_args, ( Server => RT->Config->Get('SMTPServer') );
+            push @mailer_args, ( Debug  => RT->Config->Get('SMTPDebug') );
+        }
+        else {
+            push @mailer_args, RT->Config->Get('MailParams');
+        }
+
+        unless ( $args{entity}->send(@mailer_args) ) {
+            $RT::Logger->crit( "Could not send mail." );
+            return (0);
+        }
     }
+    return 1;
 }
 
 # }}}

Modified: rt/branches/3.7-EXPERIMENTAL/lib/t/regression/04send_email.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/t/regression/04send_email.t	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/t/regression/04send_email.t	Wed Mar  8 18:24:01 2006
@@ -392,7 +392,7 @@
                  ';
 }
 
-my @input_encodings = RT->Config->Get(' EmailInputEncodings' );
+my @input_encodings = RT->Config->Get( 'EmailInputEncodings' );
 shift @input_encodings;
 RT->Config->Set(EmailInputEncodings => @input_encodings );
 RT->Config->Set(EmailOutputEncoding => 'utf-8');


More information about the Rt-commit mailing list