def process_message(self, mailfrom, rcpttos, data):
email = None
messages = []
emails = []
splitted = data.split("\r\n", 1)
subject = splitted[0] if (len(splitted) > 0) else ""
body = splitted[1] if (len(splitted) > 1) else ""
try:
for recipient in rcpttos:
num_emails = 0
res = db_service.custom_query(COUNT_QUERY_TEMPLATE.format(recipient['address'])) #TODO async
if (res is not None and len(res.current_rows) > 0):
num_emails = res.current_rows[0]['system.count(address)']
msg = Message(address=recipient['address'], message_index=num_emails, body=data, size=len(data), sender=mailfrom, created=arrow.utcnow().datetime)
messages.append(msg)
db_service.batch_save(messages, ttl=recipient['ttl(created)']) # Save with the ttl of the email account
except Exception as e:
logger.error(e)
return STATUS_ERROR
return STATUS_OK
评论列表
文章目录