smtp.py 文件源码

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

项目:fibratus 作者: rabbitstack 项目源码 文件源码
def emit(self, body, **kwargs):
        if not self._smtp:
            self._smtp = smtplib.SMTP(self._host, self._port)
        self._smtp.ehlo()
        self._smtp.starttls()
        self._smtp.ehlo()
        subject = kwargs.pop('subject', '')
        message = self._compose_message(subject, body)
        # try to authenticate with the server
        # before attempting to send the message
        try:
            self._smtp.login(self._from, self._password)
            self._smtp.sendmail(self._from, self._to, message)
        except smtplib.SMTPAuthenticationError:
            self.logger.error('Invalid SMTP credentials for %s account'
                              % self._from)
        finally:
            self._smtp.quit()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号