mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
requestsync: Add support to customize the smtp port and catch all other smtp exception
This commit is contained in:
parent
4a1c9b0cce
commit
f6b542b3c0
12
requestsync
12
requestsync
@ -183,8 +183,15 @@ if mailserver:
|
|||||||
else :
|
else :
|
||||||
mailserver = 'fiordland.ubuntu.com'
|
mailserver = 'fiordland.ubuntu.com'
|
||||||
|
|
||||||
|
# get server port
|
||||||
|
mailserver_port = os.getenv('DEBSMTP_PORT')
|
||||||
|
if mailserver_port:
|
||||||
|
print 'Using custom SMTP port:', mailserver_port
|
||||||
|
else:
|
||||||
|
mailserver_port = 25
|
||||||
|
|
||||||
# connect to the server
|
# connect to the server
|
||||||
s = smtplib.SMTP(mailserver)
|
s = smtplib.SMTP(mailserver, mailserver_port)
|
||||||
|
|
||||||
# authenticate to the server
|
# authenticate to the server
|
||||||
mailserver_user = os.getenv('DEBSMTP_USER')
|
mailserver_user = os.getenv('DEBSMTP_USER')
|
||||||
@ -195,6 +202,9 @@ if mailserver_user and mailserver_pass:
|
|||||||
except smtplib.SMTPAuthenticationError:
|
except smtplib.SMTPAuthenticationError:
|
||||||
print 'Error authenticating to the server: invalid username and password.'
|
print 'Error authenticating to the server: invalid username and password.'
|
||||||
s.quit(); sys.exit(1)
|
s.quit(); sys.exit(1)
|
||||||
|
except:
|
||||||
|
print 'Unknown SMTP error.'
|
||||||
|
s.quit(); sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
s.sendmail(myemailaddr, to, mail)
|
s.sendmail(myemailaddr, to, mail)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user