Below works for me:
steps I followed. Your context may differ and customize accordingly.
1) define a db model with the fields you want; I wanted all emails to be
stored too, so I defined this model
2) define two functions - a contact fn that gets called from template; the
contact fn itself calls another fn to send email; in the template you can
validate the fields like valid email id etc.
3) This is for sending emails from admin email; customization is needed if
otherwise
Here is the code:
def contact():
form = crud.create(db.contact_emails,
onaccept=_send_email,
next = URL('index'),
message=T("Thank you for your message"))
return dict(form=form)
def _send_email(form):
#called from successful accept of contact form
#form is sent as a first argument
mail=Mail()
mail.settings.server='gae'
mail.settings.sender="[email protected]" #This must be the email address of a
registered
#administrator for the application
mail.settings.login = None
mail.send(to='[email protected]', subject='[123-Check] Contact',
message=form.vars.body)
return