1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-05 10:36:11 +02:00

send-email: fix obscure error when encryption=tls and smtp cannot connect

When encryption=tls and we cannot connect to the SMTP server,
git-send-email was printing an obtuse perl error:

  Can't call method "command" on an undefined value
  at git-send-email line 927.

This can occur when smtp host or port is misspelled, or the network
is down, and encryption has been set to tls.

Instead we expect some familiar "Cannot connect to SERVER:PORT"
message.  Fix it to print normal "smtp can't connect" diagnostics.

Signed-off-by: Yakov Lerner <iler.ml@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Yakov Lerner 2009-09-25 15:10:21 -07:00 committed by Shawn O. Pearce
parent e648f8b6d0
commit fb3650ed10

View File

@ -921,7 +921,7 @@ sub send_message
$smtp ||= Net::SMTP->new((defined $smtp_server_port)
? "$smtp_server:$smtp_server_port"
: $smtp_server);
if ($smtp_encryption eq 'tls') {
if ($smtp_encryption eq 'tls' && $smtp) {
require Net::SMTP::SSL;
$smtp->command('STARTTLS');
$smtp->response();