diff options
-rw-r--r-- | .config/localmail/accounts/p.spek@tyil.nl.yaml | 2 | ||||
-rwxr-xr-x | .local/bin/localmail | 18 |
2 files changed, 16 insertions, 4 deletions
diff --git a/.config/localmail/accounts/p.spek@tyil.nl.yaml b/.config/localmail/accounts/p.spek@tyil.nl.yaml index d77e578..f21397b 100644 --- a/.config/localmail/accounts/p.spek@tyil.nl.yaml +++ b/.config/localmail/accounts/p.spek@tyil.nl.yaml @@ -9,7 +9,7 @@ incoming: outgoing: protocol: smtp server: tyil.email - ssl: true + starttls: true username: p.spek@tyil.nl password: source: pass 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; |