diff options
author | Patrick Spek <p.spek@tyil.nl> | 2020-03-10 09:44:55 +0100 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2021-08-14 11:59:33 +0200 |
commit | f1f243d0fb79b067af6549073cf8b75dd1ec04fa (patch) | |
tree | 1c9cdc2fb910f9ce17c915add814c4a84daffca1 /.local/bin/localmail | |
parent | fe31db8e99895ee974cf4a9abcd12dd040410503 (diff) |
Update localmail to deal with StartTLS for SMTP
Diffstat (limited to '.local/bin/localmail')
-rwxr-xr-x | .local/bin/localmail | 18 |
1 files changed, 15 insertions, 3 deletions
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; |