Skip to content

Commit fb3650e

Browse files
Yakov Lernerspearce
authored andcommitted
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 <[email protected]> Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent e648f8b commit fb3650e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

git-send-email.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ sub send_message
921921
$smtp ||= Net::SMTP->new((defined $smtp_server_port)
922922
? "$smtp_server:$smtp_server_port"
923923
: $smtp_server);
924-
if ($smtp_encryption eq 'tls') {
924+
if ($smtp_encryption eq 'tls' && $smtp) {
925925
require Net::SMTP::SSL;
926926
$smtp->command('STARTTLS');
927927
$smtp->response();

0 commit comments

Comments
 (0)