Problems with send mail.

13 views
Skip to first unread message

Капылов Данил

unread,
Sep 14, 2014, 9:12:31 AM9/14/14
to web...@googlegroups.com
Problems with send mail. 
Ad created
Letters do not have
Hosting PythonAnywhere

## configure email
mail = auth.settings.mailer
mail.settings.server = 'logging' or 'smtp.gmail.com:587'
mail.settings.sender = 'kap...@gmail.com'
mail.settings.login = 'kap...@gmail.com:secretcode'

def created_ad():
    category = get_category()
    db.ad_post.public_ad.readable = False
    db.ad_post.public_ad.writable = False
    db.ad_post.visit.readable = False
    db.ad_post.visit.writable = False
    db.ad_post.category.default = category.id
    db.ad_post.subcategory.requires = IS_IN_DB(db(db.subcategory.category == category.id), 'subcategory.id', '%(name)s')

    from gluon.utils import web2py_uuid

    db.ad_post.uuid.default = uuid = web2py_uuid()
    if auth.user:
        address = db.address(created_by=auth.user.id)
        user = auth.user
        form = SQLFORM.factory(db.ad_post, formstyle='divs')
        if form.process().accepted:
            id = db.ad_post.insert(**db.ad_post._filter_fields(form.vars))
            db.contact.insert(index_contact=address.index_contact,
                              country=address.country,
                              region=address.region,
                              city=address.city,
                              address=address.address,
                              telephone=address.telephone,
                              email=address.email,
                              ad_post=id,
                              name_contact=auth.user.first_name + " " + auth.user.last_name)
            session.flash = T('Thank you, ad completed and sent for review')
            redirect(URL('list_all_ads_by_datetime'))
            mail.send(to=[form.vars.email],
                      bcc=['Da...@mail.ru'],
                      subject='Объявление создано в категории %(title)s' % form.vars,
                      message='<html><body>' + form.vars.title + '<br/>' + form.vars.body + '<br/>' + str(
                          form.vars.price) + '</body></html>',
                      encoding='utf-8')
    else:
        form = SQLFORM.factory(db.ad_post, db.contact, formstyle='divs', )
        if form.process().accepted:
            id = db.ad_post.insert(**db.ad_post._filter_fields(form.vars))
            form.vars.ad_post = id
            id = db.contact.insert(**db.contact._filter_fields(form.vars))
            session.flash = T('Thank you, ad completed and sent for review')
            redirect(URL('list_all_ads_by_datetime'))
            mail.send(to=[form.vars.email],
                      bcc=['Da...@mail.ru'],
                      subject='Объявление создано в категории %(title)s' % form.vars,
                      message='<html><body>' + form.vars.title + '<br/>' + form.vars.body + '<br/>' + str(
                          form.vars.price) + '</body></html>',
                      encoding='utf-8')
    response.title = T('Создать новое объявление в категорию "%(name)s"') % dict(name=category.name)
    response.description = T('Создать новое объявление в категорию %(name)s') % dict(name=category.name)
    response.meta.keywords = T('Создать новое объявление в категорию %(name)s') % dict(name=category.name)
    return locals()


Reply all
Reply to author
Forward
0 new messages