예제 #1
0
    def _index_mail(self, writer, mail):
        mdict = mail.as_dict()
        header = mdict['header']
        tags = set(mdict.get('tags', {}))
        tags.add(mail.mailbox_name.lower())

        index_data = {
            'sender':
            self._empty_string_to_none(header.get('from', '')),
            'subject':
            self._empty_string_to_none(header.get('subject', '')),
            'date':
            self._format_utc_integer(header.get('date', date.mail_date_now())),
            'to':
            self._format_recipient(header, 'to'),
            'cc':
            self._format_recipient(header, 'cc'),
            'bcc':
            self._format_recipient(header, 'bcc'),
            'tag':
            u','.join(unique(tags)),
            'body':
            to_unicode(mdict.get('textPlainBody', mdict.get('body', ''))),
            'ident':
            unicode(mdict['ident']),
            'flags':
            unicode(','.join(unique(mail.flags))),
            'raw':
            unicode(mail.raw)
        }

        writer.update_document(**index_data)
    def from_dict(mail_dict):
        # TODO: implement this method and also write tests for it
        headers = {key.capitalize(): value for key, value in mail_dict.get('header', {}).items()}
        headers['Date'] = date.mail_date_now()
        body = mail_dict.get('body', '')
        tags = set(mail_dict.get('tags', []))
        status = set(mail_dict.get('status', []))
        attachments = []

        # mail_id, mailbox_name, headers=None, tags=set(), flags=set(), body=None, attachments=[]
        return LeapMail(None, None, headers, tags, set(), body, attachments)
예제 #3
0
    def from_dict(mail_dict):
        input_mail = InputMail()
        input_mail.headers = {key.capitalize(): value for key, value in mail_dict.get('header', {}).items()}

        input_mail.headers['Date'] = date.mail_date_now()
        input_mail.headers['From'] = InputMail.FROM_EMAIL_ADDRESS

        input_mail.body = mail_dict.get('body', '')
        input_mail.tags = set(mail_dict.get('tags', []))
        input_mail._status = set(mail_dict.get('status', []))
        return input_mail
예제 #4
0
    def from_python_mail(mail):
        input_mail = InputMail()
        input_mail.headers = {unicode(key.capitalize()): unicode(value) for key, value in mail.items()}
        input_mail.headers[u'Date'] = unicode(date.mail_date_now())
        input_mail.headers[u'To'] = [u'']

        for payload in mail.get_payload():
            input_mail._mime_multipart.attach(payload)
            if payload.get_content_type() == 'text/plain':
                input_mail.body = unicode(payload.as_string())
        input_mail._mime = input_mail.to_mime_multipart()
        return input_mail
예제 #5
0
 def __init__(self):
     self.mail = {
         'header': {
             'to': ['*****@*****.**'],
             'cc': ['*****@*****.**'],
             'bcc': ['*****@*****.**'],
             'subject': 'Hi! This the subject',
             'date': date.mail_date_now()
         },
         'body': "Hello,\nThis is the body of this message\n\nRegards,\n\n--\nPixelated.\n",
         'status': []
     }
예제 #6
0
    def from_dict(mail_dict, from_address):
        input_mail = InputMail()
        input_mail.headers = {key.capitalize(): value for key, value in mail_dict.get('header', {}).items()}

        input_mail.headers['Date'] = date.mail_date_now()
        input_mail.headers['From'] = from_address

        input_mail.body = mail_dict.get('body', '')
        input_mail.tags = set(mail_dict.get('tags', []))
        input_mail._status = set(mail_dict.get('status', []))
        input_mail._attachments = mail_dict.get('attachments', [])
        return input_mail
예제 #7
0
 def from_python_mail(mail):
     input_mail = InputMail()
     input_mail.headers = {key.capitalize(): value for key, value in mail.items()}
     input_mail.headers['Date'] = date.mail_date_now()
     input_mail.headers['Subject'] = mail['Subject']
     input_mail.headers['To'] = InputMail.FROM_EMAIL_ADDRESS
     input_mail._mime = MIMEMultipart()
     for payload in mail.get_payload():
         input_mail._mime.attach(payload)
         if payload.get_content_type() == 'text/plain':
             input_mail.body = payload.as_string()
     return input_mail
예제 #8
0
    def _get_recovery_mail(self, code, sender, backup_email):
        email_date = date.mail_date_now()
        recovery_mail = pkg_resources.resource_filename(
            'pixelated.assets', 'recovery.mail.%s' % (self._language))

        with open(recovery_mail) as mail_template_file:
            return message_from_string(mail_template_file.read().format(
                domain=self._domain,
                recovery_code=binascii.hexlify(code),
                backup_email=backup_email,
                sender=sender,
                date=email_date))
예제 #9
0
    def from_python_mail(mail):
        input_mail = InputMail()
        input_mail.headers = {unicode(key.capitalize()): unicode(value) for key, value in mail.items()}
        input_mail.headers[u'Date'] = unicode(date.mail_date_now())
        input_mail.headers[u'To'] = [u'']

        for payload in mail.get_payload():
            input_mail._mime_multipart.attach(payload)
            if payload.get_content_type() == 'text/plain':
                input_mail.body = unicode(payload.as_string())
        input_mail._mime = input_mail.to_mime_multipart()
        return input_mail
예제 #10
0
    def from_dict(mail_dict, from_address):
        input_mail = InputMail()
        input_mail.headers = {key.capitalize(): value for key, value in mail_dict.get('header', {}).items()}

        input_mail.headers['Date'] = date.mail_date_now()
        input_mail.headers['From'] = from_address

        input_mail.body = mail_dict.get('body', '')
        input_mail.tags = set(mail_dict.get('tags', []))
        input_mail._status = set(mail_dict.get('status', []))
        input_mail._attachments = mail_dict.get('attachments', [])
        return input_mail
예제 #11
0
 def __init__(self):
     self.mail = {
         'header': {
             'to': ['*****@*****.**'],
             'cc': ['*****@*****.**'],
             'bcc': ['*****@*****.**'],
             'subject': 'Hi! This the subject',
             'date': date.mail_date_now()
         },
         'body': "Hello,\nThis is the body of this message\n\nRegards,\n\n--\nPixelated.\n",
         'status': []
     }
     InputMail.FROM_EMAIL_ADDRESS = 'Formatted Sender <*****@*****.**>'
예제 #12
0
    def from_dict(mail_dict):
        # TODO: implement this method and also write tests for it
        headers = {
            key.capitalize(): value
            for key, value in mail_dict.get('header', {}).items()
        }
        headers['Date'] = date.mail_date_now()
        body = mail_dict.get('body', '')
        tags = set(mail_dict.get('tags', []))
        status = set(mail_dict.get('status', []))
        attachments = []

        # mail_id, mailbox_name, headers=None, tags=set(), flags=set(), body=None, attachments=[]
        return LeapMail(None, None, headers, tags, set(), body, attachments)
예제 #13
0
 def __init__(self):
     self.mail = {
         'header': {
             'to': ['*****@*****.**'],
             'cc': ['*****@*****.**'],
             'bcc': ['*****@*****.**'],
             'subject': 'Hi! This the subject',
             'date': date.mail_date_now()
         },
         'body':
         "Hello,\nThis is the body of this message\n\nRegards,\n\n--\nPixelated.\n",
         'status': []
     }
     InputMail.FROM_EMAIL_ADDRESS = 'Formatted Sender <*****@*****.**>'
예제 #14
0
    def _index_mail(self, writer, mail):
        mdict = mail.as_dict()
        header = mdict['header']
        tags = set(mdict.get('tags', {}))
        tags.add(mail.mailbox_name.lower())

        index_data = {
            'sender': self._empty_string_to_none(header.get('from', '')),
            'subject': self._empty_string_to_none(header.get('subject', '')),
            'date': self._format_utc_integer(header.get('date', date.mail_date_now())),
            'to': self._format_recipient(header, 'to'),
            'cc': self._format_recipient(header, 'cc'),
            'bcc': self._format_recipient(header, 'bcc'),
            'tag': u','.join(unique(tags)),
            'body': to_unicode(mdict.get('textPlainBody', mdict.get('body', ''))),
            'ident': unicode(mdict['ident']),
            'flags': unicode(','.join(unique(mail.flags))),
            'raw': unicode(mail.raw)
        }

        writer.update_document(**index_data)