marrow / mailer

A light-weight, modular, message representation and mail delivery framework for Python.
MIT License
276 stars 62 forks source link

Incorrect example in README #36

Closed utsengar closed 5 years ago

utsengar commented 12 years ago

I tried to use the example given in the read me:

mailer = Mailer(dict(
        transport = dict(
                use = 'smtp',
                host = 'smtp.gmail.com',
                port = '587',
                username = username,
                password = password,
                tls = 'required',
                debug = True)))
mailer.start()

message = Message(author="f@e.com", to="t@e.com")
message.subject = "Testing Marrow Mailer"
message.plain = "This is a test."
mailer.send(message)
mailer.stop()

But i gives an exception:

Traceback (most recent call last):
  File "send_email.py", line 14, in <module>
    debug = True)))
  File "/Users/user/.virtualenvs/w1/lib/python2.7/site-packages/marrow/mailer/__init__.py", line 55, in __init__
    if isinstance(config.manager, basestring):
  File "/Users/user/.virtualenvs/w1/lib/python2.7/site-packages/marrow/util/bunch.py", line 29, in __getattr__
    raise AttributeError(name)
AttributeError: manager

So, I added manager:

mailer = Mailer(dict(
        transport = dict(
                use = 'smtp',
                host = 'smtp.gmail.com',
                port = '587',
                username = username,
                password = password,
                tls = 'required',
                debug = True),
        manager = dict()))
mailer.start()

message = Message(author="f@e.com", to="t@e.com")
message.subject = "Testing Marrow Mailer"
message.plain = "This is a test."
mailer.send(message)
mailer.stop()

And it worked.

amcgregor commented 12 years ago

This is a bug in the configuration parser, not in the included README. Manager should successfully default to immediate without needing a configuration defined.