smtp_server.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:homingbot 作者: homingbot 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号