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>
Yakov Lerner committed
Sep 25, 2009 at 15:10 UTC
fb3650ed100a549f80d822f28ccf0f82e9f75f3e
1 file changed
+1
-1
git-send-email.perl
+1
-1
@@ -921,7 +921,7 @@ X-Mailer: git-send-email $gitversion
921
$smtp ||= Net::SMTP->new((defined $smtp_server_port)
922
? "$smtp_server:$smtp_server_port"
923
: $smtp_server);
924
- if ($smtp_encryption eq 'tls') {
924
+ if ($smtp_encryption eq 'tls' && $smtp) {
925
require Net::SMTP::SSL;
926
$smtp->command('STARTTLS');
927
$smtp->response();