Ejemplo n.º 1
0
def email(sender=None, receivers=(), cc=(), bcc=(),
          subject=None, content=None, encoding='utf8',
          attachments=()):
    """
    Creates an Envelope object with a HTML *content*.

    :param content: HTML content.
    :param encoding: Encoding of the email.
    :param attachments: List of filenames to
        attach to the email.
    """
    html = [HTML(content, encoding)]
    files = [Attachment(k) for k in attachments]
    return Envelope(
        headers=[
            headers.subject(subject),
            headers.sender(sender),
            headers.to(*receivers),
            headers.cc(*cc),
            headers.bcc(*bcc),
            headers.date(),
            headers.message_id(),
        ],
        enclosure=(html + files),
    )
Ejemplo n.º 2
0
def email(sender=None,
          receivers=(),
          cc=(),
          bcc=(),
          subject=None,
          content=None,
          encoding='utf8',
          attachments=()):
    """
    Creates a Collection object with a HTML *content*,
    and *attachments*.

    :param content: HTML content.
    :param encoding: Encoding of the email.
    :param attachments: List of filenames to
        attach to the email.
    """
    enclosure = [HTML(content, encoding)]
    enclosure.extend(Attachment(k) for k in attachments)
    return Collection(*enclosure,
                      headers=[
                          headers.subject(subject),
                          headers.sender(sender),
                          headers.to(*receivers),
                          headers.cc(*cc),
                          headers.bcc(*bcc),
                          headers.date(),
                          headers.message_id(),
                      ])
Ejemplo n.º 3
0
def test_sender_tuple(argtype):
    param = (
        'name <*****@*****.**>' if argtype is str else
        ('name', '*****@*****.**')
    )
    _, value = sender(param)
    assert value == 'name <*****@*****.**>'
Ejemplo n.º 4
0
 def headers(self):
     return Headers([
         ('From', '*****@*****.**'),
         sender('*****@*****.**'),
         to('*****@*****.**'),
         cc('*****@*****.**', '*****@*****.**'),
         bcc('*****@*****.**', '*****@*****.**'),
     ])
Ejemplo n.º 5
0
 def headers(self):
     return Headers([
         ('From', '*****@*****.**'),
         sender('*****@*****.**'),
         to('*****@*****.**'),
         cc('*****@*****.**', '*****@*****.**'),
         bcc('*****@*****.**', '*****@*****.**'),
     ])
Ejemplo n.º 6
0
def envelope():
    env = Envelope(
        headers=[sender('Me <*****@*****.**>'),
                 to('*****@*****.**'),
                 subject('subject')],
        enclosure=[PlainText('Hi!')],
    )
    env.string = Mock(return_value='--email--')
    return env
Ejemplo n.º 7
0
def envelope():
    env = Envelope(
        headers=[
            sender('Me <*****@*****.**>'),
            to('*****@*****.**'),
            subject('subject')
        ],
        enclosure=[PlainText('Hi!')],
    )
    env.string = Mock(return_value='--email--')
    return env
Ejemplo n.º 8
0
 def envelope(self):
     return Envelope(
         headers=[
             sender('Me <*****@*****.**>'),
             to('*****@*****.**', '*****@*****.**'),
             subject('subject'),
         ],
         enclosure=[
             PlainText('hi!'),
             PlainText('bye!'),
         ],
     )
Ejemplo n.º 9
0
def test_sender_tuple(argtype):
    param = ('name', '*****@*****.**')
    if argtype is str:
        param = '{0} <{1}>'.format(*param)
    _, value = sender(param)
    assert value == 'name <*****@*****.**>'
Ejemplo n.º 10
0
def test_sender_tuple(argtype):
    param = ('name', '*****@*****.**')
    if argtype is str:
        param = '{0} <{1}>'.format(*param)
    _, value = sender(param)
    assert value == 'name <*****@*****.**>'
Ejemplo n.º 11
0
def test_sender_tuple(argtype):
    param = ('name <*****@*****.**>' if argtype is str else
             ('name', '*****@*****.**'))
    _, value = sender(param)
    assert value == 'name <*****@*****.**>'