e.g.
*private/appconfig.ini*
[smtp]
server = smtp.gmail.com:587
sender = [email protected]
login = email:password
*models/db.py*
from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
auth = Auth(db)
mail = auth.settings.mailer
mail.settings.server = 'logging' if request.is_local else
myconf.take('smtp.sender')
mail.settings.sender = myconf.take('smtp.sender')
mail.settings.login = myconf.take('smtp.login')
db.define_table('contact_us',
Field('name'),
Field('email'),
Field('phone'),
Field('address', 'text'),
Field('messages', 'text'),
format = '%(email)s %(name)s')
*controllers/default.py*
def contact_us():
form = SQLFORM(db.contact_us)
email = [email protected]
if form.process().accepted:
mail.send(email,
'Contacted from %s' % request.env.http_host,
'<html><table><tr><td><b>Name</b></td><td>%s</td></tr><tr><td><b>Email</b></td><td>%s</td></tr><tr><td><b>Phone</b></td><td>%s</td></tr><tr><td><b>Address</b></td><td>%s</td></tr><tr><td><b>Messages</b></td><td>%s</td></tr></table></html>'
% (form.vars.name, form.vars.email, form.vars.phone, form.vars.address,
form.vars.messages))
response.flash = T('messages sent')
elif form.errors:
response.flash = T('there is an error in the form')
else:
response.flash = T('please fill out the form')
return dict(form = form)
p.s.
you can modify to suit with your requirement
best regards,
stifan
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.