# commit 'git-send-email: add support for TLS via Net::SMTP::SSL' causes warnings

4 messages from 2008-06-26 to 2008-06-26. Participants: Kevin Ballard, Thomas Rast.
Thread: https://gitlist.dev/t/14169

## Kevin Ballard, 2008-06-26 20:19

Subject: commit 'git-send-email: add support for TLS via Net::SMTP::SSL' causes warnings
Message-ID: <DF091369-1771-4405-8705-BDBC59C7E48A@sb.org>
URL: https://gitlist.dev/e/DF091369-1771-4405-8705-BDBC59C7E48A%40sb.org

```
Your recent commit to next (f6bebd1) causes warnings when no form of  
encryption is specified. Specifically, lines 755 and 765 reference  
$smtp_encryption, but when no encryption is given at all this variable  
is undefined.

-Kevin Ballard

-- 
Kevin Ballard
http://kevin.sb.org
kevin@sb.org
http://www.tildesoft.com

```

## Kevin Ballard, 2008-06-26 20:36

Subject: [PATCH] git-send-email: Fix warning triggered by f6bebd12 when no encryption is set
Message-ID: <1214512599-88902-1-git-send-email-kevin@sb.org>
URL: https://gitlist.dev/e/1214512599-88902-1-git-send-email-kevin%40sb.org
In-Reply-To: <DF091369-1771-4405-8705-BDBC59C7E48A@sb.org>

```
---
 git-send-email.perl |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 60a6551..b93cd40 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -299,6 +299,8 @@ sub read_config {
 			$smtp_encryption = $enc;
 		} elsif (Git::config_bool(@repo, "$prefix.smtpssl")) {
 			$smtp_encryption = 'ssl';
+		} else {
+			$smtp_encryption = '';
 		}
 	}
 }
-- 
1.5.6.1.180.g7b731

```

## Thomas Rast, 2008-06-26 20:48

Subject: Re: commit 'git-send-email: add support for TLS via Net::SMTP::SSL' causes warnings
Message-ID: <200806262248.02866.trast@student.ethz.ch>
URL: https://gitlist.dev/e/200806262248.02866.trast%40student.ethz.ch
In-Reply-To: <DF091369-1771-4405-8705-BDBC59C7E48A@sb.org>

```
Kevin Ballard wrote:
> Your recent commit to next (f6bebd1) causes warnings when no form of  
> encryption is specified. Specifically, lines 755 and 765 reference  
> $smtp_encryption, but when no encryption is given at all this variable  
> is undefined.

Sorry for the oversight on my part, and thanks for the fix! :-)

- Thomas

-- 
Thomas Rast
trast@student.ethz.ch


```

## Thomas Rast, 2008-06-26 21:03

Subject: Re: commit 'git-send-email: add support for TLS via Net::SMTP::SSL' causes warnings
Message-ID: <200806262303.23269.trast@student.ethz.ch>
URL: https://gitlist.dev/e/200806262303.23269.trast%40student.ethz.ch
In-Reply-To: <200806262248.02866.trast@student.ethz.ch>

```
I wrote:
> 
> and thanks for the fix

Well, actually at second glance your fix is wrong.  Putting it in
read_config() means it will be executed the first time around already,
when we read the identity's settings.  So with the patch,
$smtp_encryption is set to '' during identity parsing, and any value
set in the global [sendemail] section never takes effect.

Let's do the following instead.  Sorry for all the noise.

-- 8< --
git-send-email: prevent undefined variable warnings if no encryption is set

With the previous patch, not configuring any encryption (either on or
off) would leave $smtp_encryption undefined.  We simply set it to the
empty string in that case.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
 git-send-email.perl |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 7630720..edb12c2 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -313,6 +313,9 @@ foreach my $setting (values %config_bool_settings) {
 	${$setting->[0]} = $setting->[1] unless (defined (${$setting->[0]}));
 }
 
+# 'default' encryption is none -- this only prevents a warning
+$smtp_encryption = '' unless (defined $smtp_encryption);
+
 # Set CC suppressions
 my(%suppress_cc);
 if (@suppress_cc) {
-- 
1.5.6.1.187.g35a8

```
