Subject: | [PATCH] Allow SMTP AUTH and alternate SMTP ports if MIME::Lite is the mailer. |
Patch attached.
Subject: | Test-Smoke-SMTP-AUTH.patch |
Index: configsmoke.pl
===================================================================
--- configsmoke.pl (revision 1272)
+++ configsmoke.pl (working copy)
@@ -526,6 +526,23 @@
alt => [ ],
dft => 'localhost',
},
+ mport => {
+ msg => 'What port is your SMTP server on?',
+ alt => [qw( 25 587 )],
+ dft => '25',
+ },
+ muser => {
+ msg => 'If authorization is required for your SMTP server, what is your username?' .
+ "\nLeave empty to not use SMTP AUTH",
+ alt => [ ],
+ dft => '',
+ },
+ mpass => {
+ msg => 'If authorization is required for your SMTP server, what is your password?' .
+ "\nLeave empty to not use SMTP AUTH",
+ alt => [ ],
+ dft => '',
+ },
to => {
msg => <<EOMSG,
@@ -1222,7 +1239,7 @@
/^sendmail$/ && do {
$arg = 'from';
$config{ $arg } = prompt( $arg );
- };
+ };
/^(?:Mail::Sendmail|MIME::Lite)$/ && do {
$arg = 'from';
@@ -1232,6 +1249,18 @@
$arg = 'mserver';
$config{ $arg } = prompt( $arg );
};
+
+ /^MIME::Lite$/ && do {
+ $arg = 'mport';
+ $config{ $arg } = prompt( $arg );
+
+ $arg = 'muser';
+ $config{ $arg } = prompt( $arg );
+
+ $arg = 'mpass';
+ $config{ $arg } = prompt( $arg );
+ };
+
}
$arg = 'ccp5p_onfail';
$config{ $arg } = prompt_yn( $arg );
@@ -1677,7 +1706,7 @@
qw( force_c_locale locale defaultenv ),
# Report related
- qw( mail mail_type mserver from to ccp5p_onfail
+ qw( mail mail_type mserver mport muser mpass from to ccp5p_onfail
swcc cc swbcc bcc ),
# Archive reports and logfile
Index: lib/Test/Smoke/Mailer.pm
===================================================================
--- lib/Test/Smoke/Mailer.pm (revision 1272)
+++ lib/Test/Smoke/Mailer.pm (working copy)
@@ -22,6 +22,9 @@
df_bcc => '',
df_ccp5p_onfail => 0,
df_mserver => 'localhost',
+ df_mport => 25,
+ df_muser => '',
+ df_mpass => '',
df_mailbin => 'mail',
mail => [qw( bcc cc mailbin )],
@@ -30,7 +33,7 @@
df_sendmailbin => 'sendmail',
sendmail => [qw( from bcc cc sendmailbin )],
'Mail::Sendmail' => [qw( from bcc cc mserver )],
- 'MIME::Lite' => [qw( from bcc cc mserver )],
+ 'MIME::Lite' => [qw( from bcc cc mserver mport muser mpass )],
valid_mailer => { sendmail => 1, mail => 1, mailx => 1,
'Mail::Sendmail' => 1, 'MIME::Lite' => 1, },
@@ -65,6 +68,9 @@
mhowto => [Module::Name|sendmail|mail|mailx]
mserver => an SMTP server || localhost
+ mport => The port that the SMTP server is on
+ muser => user for servers that require SMTP AUTH
+ mpass => user for servers that require SMTP AUTH
mbin => the full path to the mail binary
mto => list of addresses (comma separated!)
mfrom => single address
@@ -440,6 +446,9 @@
* from
* cc
* v
+ * mport
+ * muser
+ * mpass
=cut
@@ -476,7 +485,15 @@
$message{Bcc} = $self->{bcc} if $self->{bcc};
$message{From} = $self->{from} if $self->{from};
- MIME::Lite->send( smtp => $self->{mserver}, Debug => ( $self->{v} > 1 ) )
+ my %params = (
+ Debug => ( $self->{v} > 1 ),
+ Port => $self->{mport},
+ );
+
+ $params{AuthUser} = $self->{muser} if $self->{muser};
+ $params{AuthPass} = $self->{mpass} if $self->{mpass};
+
+ MIME::Lite->send( smtp => $self->{mserver}, %params )
if $self->{mserver};
my $ml_msg = MIME::Lite->new( %message );
Index: mailrpt.pl
===================================================================
--- mailrpt.pl (revision 1272)
+++ mailrpt.pl (working copy)
@@ -29,6 +29,9 @@
ccp5p_onfail => undef,
from => undef,
mserver => undef,
+ mport => undef,
+ muser => undef,
+ mpass => undef,
v => undef,
rptfile => 'mktest.rpt',
@@ -96,11 +99,19 @@
--from <address>
-=item * B<options for> -t Mail::Sendmail | MIME::Lite
+=item * B<options for> -t Mail::Sendmail
--from <address>
--mserver <smtpserver> (localhost)
+=item * B<options for> -t MIME::Lite
+
+ --from <address>
+ --mserver <smtpserver> (localhost)
+ --mport <port> (25)
+ --muser <smtpuser>
+ --mpass <smtppass>
+
=back
=head1 DESCRIPTION
@@ -114,7 +125,7 @@
'type|t=s', 'ddir|d=s', 'to=s', 'cc=s', 'bcc=s', 'ccp5p_onfail!',
'v|verbose=i',
- 'from=s', 'mserver=s',
+ 'from=s', 'mserver=s', 'muser=s', 'mpass=s', 'mport=i',
'help|h', 'man',