Allow specification of non-default port when sending email.
authorGreg Sabino Mullane <greg@endpoint.com>
Sun, 14 Dec 2014 18:35:37 +0000 (13:35 -0500)
committerGreg Sabino Mullane <greg@endpoint.com>
Sun, 14 Dec 2014 18:35:37 +0000 (13:35 -0500)
Attempt support for SASL auth as well (untested)

Bucardo.pm
bucardo.schema

index ea4e357b626f4a1f65f4adf0a719eac8280db476..b1e277be2acd216165f32a8e3e340e3722402319 100644 (file)
@@ -10097,6 +10097,7 @@ sub send_mail {
 
     ## Where do we connect to?
     my $smtphost = $config{default_email_host} || 'localhost';
+    my $smtpport = $config{default_email_port} || 25;
 
     ## Send normal email
     ## Do not send it if the 'example.com' default value is still in place
@@ -10106,9 +10107,18 @@ sub send_mail {
         eval {
             my $smtp = Net::SMTP->new(
                 Host    => $smtphost,
+                Port    => $smtpport,
                 Hello   => $hostname,
                 Timeout => 15
                 );
+
+            if ($config{email_auth_user} and $config{email_auth_pass}) {
+                ## Requires Authen::SASL
+                my ($auser,$apass) = ($config{email_auth_user}, $config{email_auth_pass});
+                $self->glog("Attempting Net::SMTP::auth with user $auser", LOG_DEBUG);
+                $smtp->auth($auser, $apass);
+            }
+
             $smtp->mail($from);
             $smtp->to($arg->{to});
             $smtp->data();
index 5db9056e7383d9e5b17c8dcf70af627f16ef8f26..636ab457a7612bcf3499d9925cd252aca455537e 100644 (file)
@@ -162,8 +162,11 @@ bucardo_vac|1|Do we want the automatic VAC daemon to run?
 default_email_from|nobody@example.com|Who the alert emails are sent as
 default_email_to|nobody@example.com|Who to send alert emails to
 default_email_host|localhost|Which host to send email through
+default_email_port|25|Which port to send email through
 default_conflict_strategy|bucardo_latest|Default conflict strategy for all syncs
 email_debug_file||File to save a copy of all outgoing emails to
+email_auth_user||User to use for email authentication via Net::SMTP
+email_auth_pass||Password to use for email authentication via Net::SMTP
 flatfile_dir|.|Directory to store the flatfile output inside of
 host_safety_check||Regex to make sure we don't accidentally run where we should not
 isolation_level|repeatable read|Default isolation level: can be serializable or repeatable read