1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
Description: try / except around mail functions
add try / except around mail functions to
prevent python errors messages
Author: Jörg Frings-Fürst <debian@jff-webhosting.net>
Forwarded: via mail
Applied-Upstream: <version|URL|commit, identifies patches merged upstream, optional>
Reviewed-by:
Last-Update: 2014-05-22
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
Index: trunk/mwc.py
===================================================================
--- trunk.orig/mwc.py 2014-05-22 08:43:11.758523862 +0200
+++ trunk/mwc.py 2014-05-22 08:50:09.336051435 +0200
@@ -212,15 +212,27 @@
mail['Subject'] = Header(subject, defaultEncoding)
# initialize session once, not each time this method gets called
- if mailsession is None:
- mailsession = smtplib.SMTP(config.smtphost, config.smtpport)
- if config.useTLS:
- mailsession.ehlo()
- mailsession.starttls()
- mailsession.login(config.smtpusername, config.smtppwd)
-
- mailsession.sendmail(config.sender, receiver.split(','), mail.as_string())
-
+ #
+ # add try / except to open mailsession
+ #
+ try:
+ if mailsession is None:
+ mailsession = smtplib.SMTP(config.smtphost, config.smtpport)
+ if config.useTLS:
+ mailsession.ehlo()
+ mailsession.starttls()
+ mailsession.login(config.smtpusername, config.smtppwd)
+ #
+ # add try / except to send mail
+ #
+ except:
+ printf('Error: Open smtp-session')
+ exit(4)
+ try:
+ mailsession.sendmail(config.sender, receiver.split(','), mail.as_string())
+ except:
+ printf('Error: sendmail')
+ exit(5)
# returns a list of all content that is stored locally for a specific site
def getFileContents(shortname):
|