Skip to content

Commit

Permalink
mail: connect() error tweak (#536)
Browse files Browse the repository at this point in the history
* When sending a mail message we need to connect to a relay host
* Append the system error string to the nice error in $emesg, which is already terminated with a newline
* This makes the error take up 2 lines but I think it's still better because we can see more specific info on what failed

%RELAYHOST=127.0.0.1 perl mail go@google.com # now shows...
Unable to connect to the specified relay host
IO::Socket::INET: connect: Connection refused
  • Loading branch information
mknos committed Apr 5, 2024
1 parent 5f652dc commit 30cc586
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions bin/mail
Expand Up @@ -112,9 +112,7 @@ sub new {
Type => SOCK_STREAM,
Timeout => 15,
);
if (! $socket) {
die $emsg;
}
die $emsg . $IO::Socket::errstr . "\n" unless $socket;
my($ofh)=select($socket); $|=1; select($ofh);

# Get the SMTP header
Expand Down

0 comments on commit 30cc586

Please sign in to comment.