def post(self): """ Manage post """ email = self.get_argument('email') name = self.get_argument('name') question = self.get_argument('question') answer = self.get_argument('answer') message = self.get_argument('message') if email and name and question and answer and message and question == answer: """ Send mail""" try: model = EmailModel() # Contact email is the default if not model.shortcut_exists(getattr(private_settings, "CONTACT_EMAIL", "contact_email")): self.write("The email preferences are not set") else: # Replace all tags. email_object = model.find_by_shortcut(private_settings.CONTACT_EMAIL) email_pref = PreferenceModel().get_mail_server() content = micro_template(email_object['content'], { 'sender': name, 'email': email, 'message': message }) send_mail(email, email_pref['sender'], email_object['title'], content, host_pref=email_pref) self.write("ok") except Exception as e: self.write("error: " + str(e))