-
Notifications
You must be signed in to change notification settings - Fork 0
/
urls.py
43 lines (37 loc) · 1.06 KB
/
urls.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#from app import app
import os
from flask import Flask, render_template, request, flash, redirect, url_for
from forms import ContactForm
from flask.ext.mail import Message, Mail
# Set up mail to send properly
mail=Mail(app)
app.config.update(
DEBUG=True,
#EMAIL SETTINGS
MAIL_SERVER = '',
MAIL_PORT = 587,
MAIL_USE_SSL = False,
MAIL_USE_TLS = True,
MAIL_USERNAME = '',
MAIL_PASSWORD = ''
)
mail=Mail(app)
# Contact function to control error handling and submission
def contact():
form = ContactForm()
if request.method == 'POST':
if form.validate() == False:
flash('Please enter valid text')
return render_template('contact.html', form = form)
else:
msg = Message(form.subject.data, sender='[SENDER EMAIL]', recipients=['[RECIPIENT EMAIL]'])
msg.body = """
From: %s %s <%s>
%s
""" % (form.firstName.data, form.lastName.data, form.email.data, form.message.data)
mail.send(msg)
return render_template('contact.html', success=True)
elif request.method == 'GET':
return render_template('contact.html',
title = 'Contact Us',
form = form)