Exemplo n.º 1
0
def contact_us():
    form = ContactUsForm()

    if request.method == 'POST':
        if form.validate() == True:
            msg = Message('New Message SELF-16',
                          sender=('SELF-16 DoNotReply', MAIL_USERNAME),
                          recipients = RECIPIENTS)
            msg.body = """Name:
%s %s

Email:
%s <mailto:%s>

Message:
%s

________________________________

This message was submitted from your website contact form""" % (form.first_name.data, form.last_name.data, form.email.data, form.email.data, form.message.data)
            mail.send(msg)

            return render_template('contact-us.html', success=True)
        else:
            render_template('contact-us.html', form=form)

    elif request.method == 'GET':
        return render_template('contact-us.html', form=form)
Exemplo n.º 2
0
def contactUs():
    contactUsForm = ContactUsForm(request.form)

    if request.method == 'POST' and contactUsForm.validate():
        contactDict = {}
        db = shelve.open('storage.db', 'c')
        try:
            contactDict = db['Contact']
        except:
            print("Error in retrieving Items from storage.db.")
        contact = ContactUs.Contact(contactUsForm.fname.data,
                                    contactUsForm.lname.data,
                                    contactUsForm.email.data,
                                    contactUsForm.text.data)
        contactDict[contact.get_email()] = contact
        db['Contact'] = contactDict
        db.close()
        return redirect(url_for('home'))
    return render_template('contactUs.html', form=contactUsForm)