# [PATCH 1/1] Support configurable SMTP port for stg mail.

2 messages from 2005-07-21 to 2005-07-21. Participants: Bryan larsen, Catalin Marinas.
Thread: https://gitlist.dev/t/1288

## Bryan larsen, 2005-07-21 20:20

Subject: [PATCH 1/1] Support configurable SMTP port for stg mail.
Message-ID: <20050721202058.8047.77221.stgit@h164.c77.b0.tor.eicat.ca>
URL: https://gitlist.dev/e/20050721202058.8047.77221.stgit%40h164.c77.b0.tor.eicat.ca

```
The example configuration file makes it appear that the SMTP port is configurable.  Make it so.

Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---

 stgit/commands/mail.py |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/stgit/commands/mail.py b/stgit/commands/mail.py
--- a/stgit/commands/mail.py
+++ b/stgit/commands/mail.py
@@ -68,8 +68,14 @@ def __parse_addresses(string):
 def __send_message(smtpserver, from_addr, to_addr_list, msg, sleep):
     """Send the message using the given SMTP server
     """
+    if smtpserver.find(':')==-1:
+        smtpport=25
+    else:
+        smtpport=int(smtpserver[smtpserver.find(':')+1:])
+        smtpserver=smtpserver[:smtpserver.find(':')]
+
     try:
-        s = smtplib.SMTP(smtpserver)
+        s = smtplib.SMTP(smtpserver, smtpport)
     except Exception, err:
         raise CmdException, str(err)
 

```

## Catalin Marinas, 2005-07-21 20:55

Subject: Re: [PATCH 1/1] Support configurable SMTP port for stg mail.
Message-ID: <1121979346.7654.3.camel@localhost.localdomain>
URL: https://gitlist.dev/e/1121979346.7654.3.camel%40localhost.localdomain
In-Reply-To: <20050721202058.8047.77221.stgit@h164.c77.b0.tor.eicat.ca>

```
On Thu, 2005-07-21 at 16:20 -0400, Bryan larsen wrote:
> The example configuration file makes it appear that the SMTP port is configurable.  Make it so.

The documentation for smtplib.SMTP says that the smtpserver parameter is
passed to connect(). This latter function parses the smtpserver for
'server:port' like strings and does the right thing. I tried it with
Python 2.3 and it seems to work fine without this patch.

Thanks anyway.

-- 
Catalin

```
