diff options
Diffstat (limited to '.local')
-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; |