Ejemplo n.º 1
0
	def check(self, listAddress):
		'''Check for messages from listAddress and return a list of missing chirps'''
		accounts = self.db.get_accounts(listAddress)
		if len(accounts) == 0:
			raise Exception("No receipients for listAddress '%s'", (listAddress,))
		for (listAddress, address, imapserver, password) in accounts:
			mail = emailutils.get_imap(imapserver, address, password)
			these_subjects = []
			for uid in emailutils.get_mail_uids(mail):
				message = emailutils.get_message(mail, uid)
				if self.processMessage(address, message):
					emailutils.delete_message(mail, uid)
			emailutils.close(mail)
		return self.db.get_missing_pongs(listAddress)
Ejemplo n.º 2
0
import emailutils
import smtplib
from email import message

PASSWORD="******"
ACCOUNTS = [('mail.example.com', '*****@*****.**', PASSWORD)]
DESTINATION="*****@*****.**"

youve_got_mail = False
all_subjects = {}

for account in ACCOUNTS:
	mail = emailutils.get_imap(account[0], account[1], account[2])
	these_subjects = []
	for uid in emailutils.get_mail_uids(mail):
		message = emailutils.get_message(mail, uid)
		these_subjects.append(message['subject'])
		youve_got_mail = True
	all_subjects[account[1]] = these_subjects


if youve_got_mail:
	msg = ""
	for account in all_subjects:
		msg = msg + "# Messages for %s\n" % account
		for subject in all_subjects[account]:
			msg = msg + " * %s\n" % subject
		msg = msg + "\n"

	digest_message = message.Message()
	digest_message.set_payload(msg)