Exemplo n.º 1
0
def create_mail_recipient(message, toemail, toname, isto):
    """
    Attempts to create a MailRecipient object handling nasty unicode issues
    """
    try:
        return MailRecipient(message=message, toEmail=toemail,
                             toName=toname, isTo=isto)
    except UnicodeDecodeError:
        pass
    return MailRecipient(message=message, toEmail=decodeh.decode(toemail),
                         toName=decodeh.decode(toname), isTo=isto)
Exemplo n.º 2
0
def create_mail_reference(message, reference):
    """
    Attempts to create a mail reference object.  First tries the easy
    method where everything is assumed to be proper unicode.  If that
    doesn't work then it uses decodeh.decode to brute force whatever
    it is.

    @param message: a dbobjects.MailMessage
    @param reference: the string reference
    """
    try:
        return MailReference(message=message, reference=reference)
    except UnicodeDecodeError:
        pass
    return MailReference(message=message, reference=decodeh.decode(reference))
Exemplo n.º 3
0
def create_mail_message(fromemail, fromname, subject, body, date, messageid, maillist, archive, replyto):
    try:
        return MailMessage(fromEmail=fromemail, fromName=fromname, subject=subject, body=body,
                            date=date, messageID=messageid, list=maillist,
                            archive=archive, replyTo=replyto)
    except UnicodeDecodeError:
        pass
    return MailMessage(fromEmail=decodeh.decode(fromemail), fromName=decodeh.decode(fromname),
                       subject=decodeh.decode(subject), body=decodeh.decode(body),
                       date=date, messageID=decodeh.decode(messageid), list=maillist,
                       archive=archive, replyTo=decodeh.decode(replyto))