MCPcopy Index your code
hub / github.com/Bitmessage/PyBitmessage / run

Method run

src/class_smtpDeliver.py:36–111  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

34 return cls._instance
35
36 def run(self):
37 while state.shutdown == 0:
38 command, data = queues.UISignalQueue.get()
39 if command == 'writeNewAddressToTable':
40 label, address, streamNumber = data
41 pass
42 elif command == 'updateStatusBar':
43 pass
44 elif command == 'updateSentItemStatusByToAddress':
45 toAddress, message = data
46 pass
47 elif command == 'updateSentItemStatusByAckdata':
48 ackData, message = data
49 pass
50 elif command == 'displayNewInboxMessage':
51 inventoryHash, toAddress, fromAddress, subject, body = data
52 dest = BMConfigParser().safeGet("bitmessagesettings", "smtpdeliver", '')
53 if dest == '':
54 continue
55 try:
56 u = urlparse.urlparse(dest)
57 to = urlparse.parse_qs(u.query)['to']
58 client = smtplib.SMTP(u.hostname, u.port)
59 msg = MIMEText(body, 'plain', 'utf-8')
60 msg['Subject'] = Header(subject, 'utf-8')
61 msg['From'] = fromAddress + '@' + SMTPDOMAIN
62 toLabel = map (lambda y: BMConfigParser().safeGet(y, "label"), filter(lambda x: x == toAddress, BMConfigParser().addresses()))
63 if len(toLabel) > 0:
64 msg['To'] = "\"%s\" <%s>" % (Header(toLabel[0], 'utf-8'), toAddress + '@' + SMTPDOMAIN)
65 else:
66 msg['To'] = toAddress + '@' + SMTPDOMAIN
67 client.ehlo()
68 client.starttls()
69 client.ehlo()
70 client.sendmail(msg['From'], [to], msg.as_string())
71 logger.info("Delivered via SMTP to %s through %s:%i ...", to, u.hostname, u.port)
72 client.quit()
73 except:
74 logger.error("smtp delivery error", exc_info=True)
75 elif command == 'displayNewSentMessage':
76 toAddress, fromLabel, fromAddress, subject, message, ackdata = data
77 pass
78 elif command == 'updateNetworkStatusTab':
79 pass
80 elif command == 'updateNumberOfMessagesProcessed':
81 pass
82 elif command == 'updateNumberOfPubkeysProcessed':
83 pass
84 elif command == 'updateNumberOfBroadcastsProcessed':
85 pass
86 elif command == 'setStatusIcon':
87 pass
88 elif command == 'changedInboxUnread':
89 pass
90 elif command == 'rerenderMessagelistFromLabels':
91 pass
92 elif command == 'rerenderMessagelistToLabels':
93 pass

Callers

nothing calls this directly

Calls 6

BMConfigParserClass · 0.90
safeGetMethod · 0.80
addressesMethod · 0.80
quitMethod · 0.80
getMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected