From f1f243d0fb79b067af6549073cf8b75dd1ec04fa Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Tue, 10 Mar 2020 09:44:55 +0100 Subject: Update localmail to deal with StartTLS for SMTP --- .local/bin/localmail | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to '.local') diff --git a/.local/bin/localmail b/.local/bin/localmail index dc1092a..eea4511 100755 --- a/.local/bin/localmail +++ b/.local/bin/localmail @@ -143,18 +143,30 @@ sub send ($config, @args) { } my $current = $config->{accounts}{$senders{$from}}{outgoing}; + my $port = $current->{port} // ($current->{ssl} ? 465 : 25); - say " Connecting to ".$current->{server}; + say " Connecting to ".$current->{server}.':'.$port; # Send the email my $connection = Net::SMTP->new( $current->{server}, - SSL => $current->{ssl}, + Port => $port, + SSL => $current->{ssl} // 0, Timeout => $current->{timeout} // 5, + Debug => 1, ); - say " Authenticating"; + if (!$connection) { + say " Failed: ".$@; + next; + } + if ($current->{starttls}) { + say " StartTLS"; + $connection->starttls(); + } + + say " Authenticating"; if (!$connection->auth($current->{username}, $current->{password}{plain})) { say " Failed: ".$connection->message; next; -- cgit v1.1