Beispiel #1
0
def mailer_settings_factory(settings, prefix='photoapp.mailer.'):
    """Returns the correctly configured specific implementation
    of an IMailer object based on settings.

    The specific implementation is determined by the `type`
    setting, currently:

    smtp:
        send mail from SMTP server
    console:
        print mail messages to stdout (does not send any mail)

    `console` is the default type.

    Args:
        settings: dict of settings
        prefix: specific prefix to find mailer-specific settings

    Returns:
        IMailer instance
    """

    classname = settings.get(prefix + 'class',
                             'photoapp.mail.SMTP_Mailer')

    mailer_cls = DottedNameResolver().resolve(classname)
    return mailer_cls.from_settings(settings, prefix)