Permalink
Browse files

Added support for SASL authentication to Net::SMTP

if you are using Nt::SMTP and you set the MV_SMTPUSER and MV_SMTPPASS with  your
authenticated username and password respectively then IC will now authenticate
to the target server.
  • Loading branch information...
1 parent fc5752e commit de0b7c018c58de7ef6c31899b36934441c61201c @pajamian committed Sep 11, 2011
Showing with 14 additions and 4 deletions.
  1. +11 −4 lib/Vend/Email.pm
  2. +3 −0 lib/Vend/Util.pm
View
@@ -438,14 +438,18 @@ sub tag_mime_lite_email {
# Unlike in previous implementations in IC, MV_SMTPHOST is not required.
# (Net::SMTP gets to figure out the host).
my $smtphost = $::Variable->{MV_SMTPHOST} ||
- $Global::Variable->{MV_SMTPHOST};
+ $Global::Variable->{MV_SMTPHOST} || undef;
+
+ my $user = $::Variable->{MV_SMTPUSER} || $Global::Variable->{MV_SMTPUSER};
+ my $pass = $::Variable->{MV_SMTPPASS} || $Global::Variable->{MV_SMTPPASS};
my $timeout = $::Variable->{MV_SMTP_TIMEOUT} ||
$Global::Variable->{MV_SMTP_TIMEOUT} || 60;
- MIME::Lite->send('smtp', $smtphost ?
- ($smtphost, $timeout) :
- ($timeout) );
+ my @args = (Timeout => $timeout);
+ push @args, (AuthUser => $user, AuthPass => $pass) if $user && $pass;
+
+ MIME::Lite->send('smtp', $smtphost, @args);
} else { # (We know we're sending using sendmail now).
@@ -665,6 +669,8 @@ sub send_mail_legacy {
SMTP: {
my $mhost = $::Variable->{MV_SMTPHOST} || $Global::Variable->{MV_SMTPHOST};
+ my $user = $::Variable->{MV_SMTPUSER} || $Global::Variable->{MV_SMTPUSER};
+ my $pass = $::Variable->{MV_SMTPPASS} || $Global::Variable->{MV_SMTPPASS};
my $helo = $Global::Variable->{MV_HELO} || $::Variable->{SERVER_NAME};
last SMTP unless $none and $mhost;
eval {
@@ -677,6 +683,7 @@ sub send_mail_legacy {
undef $none;
my $smtp = Net::SMTP->new($mhost, Debug => $Global::Variable->{DEBUG}, Hello => $helo);
+ $smtp->auth($user, $pass) if $user && $pass;
#::logDebug("smtp object $smtp");
my $from = $::Variable->{MV_MAILFROM}
View
@@ -2127,6 +2127,8 @@ sub send_mail {
SMTP: {
my $mhost = $::Variable->{MV_SMTPHOST} || $Global::Variable->{MV_SMTPHOST};
+ my $user = $::Variable->{MV_SMTPUSER} || $Global::Variable->{MV_SMTPUSER};
+ my $pass = $::Variable->{MV_SMTPPASS} || $Global::Variable->{MV_SMTPPASS};
my $helo = $Global::Variable->{MV_HELO} || $::Variable->{SERVER_NAME};
last SMTP unless $none and $mhost;
eval {
@@ -2139,6 +2141,7 @@ sub send_mail {
undef $none;
my $smtp = Net::SMTP->new($mhost, Debug => $Global::Variable->{DEBUG}, Hello => $helo) or last SMTP;
+ $smtp->auth($user, $pass) if $user && $pass;
#::logDebug("smtp object $smtp");
my $from = $::Variable->{MV_MAILFROM}

0 comments on commit de0b7c0

Please sign in to comment.