def contact(): if request.method == 'POST': # different dropdowns -> mail for different people mail_to = { "data": os.environ.get('DATA_RECIPIENT', GENERIC_RECIPIENT), "casestudies": os.environ.get('CASESTUDIES_RECIPIENT', GENERIC_RECIPIENT), "declaration": os.environ.get('DECLARATION_RECIPIENT', GENERIC_RECIPIENT), "resources": os.environ.get('RESOURCES_RECIPIENT', GENERIC_RECIPIENT), "other": os.environ.get('OTHER_RECIPIENT', GENERIC_RECIPIENT) }[request.form.get('issue').lower()] addr = request.form.get('email') msg = request.form.get('message') if msg and addr and '@' in addr: mail = PMMail(api_key=POSTMARK_API_KEY, sender=POSTMARK_SENDER) mail.subject = '[MPT] contact from %s' % addr mail.to = mail_to mail.reply_to = addr mail.text_body = msg mail.send() return redirect('/thanks') return render_template('contact.html')
def send_postmark(to="", bcc="", subject="", plaintext=""): """ Send an email via Postmark. Used when the application is deployed on Heroku. """ try: message = PMMail(api_key=conf.POSTMARK_API_KEY, subject=subject, sender=conf.NOTIFICATION_EMAIL, text_body=plaintext) message.to = to if bcc != "": message.bcc = bcc message.send() except Exception as e: logger.exception("send_postmark raised:") raise e
def send_postmark(to="", bcc="", subject="", plaintext=""): """ Send an email via Postmark. Used when the application is deployed on Heroku. """ try: message = PMMail(api_key = conf.POSTMARK_API_KEY, subject = subject, sender = conf.NOTIFICATION_EMAIL, text_body = plaintext) message.to = to if bcc != "": message.bcc = bcc message.send() except Exception as e: logger.exception("send_postmark raised:") raise e
def send_postmark(to="", bcc="", subject="", plaintext=""): """ Send an email via Postmark. Used when the application is deployed on Heroku. Note: The Postmark team has chosen not to continue development of the Heroku add-on as of June 30, 2017. Newspipe is now using SendGrid when deployed on Heroku. """ from postmark import PMMail try: message = PMMail(api_key=conf.POSTMARK_API_KEY, subject=subject, sender=conf.NOTIFICATION_EMAIL, text_body=plaintext) message.to = to if bcc != "": message.bcc = bcc message.send() except Exception as e: logger.exception('send_postmark raised:') raise e
def send_postmark(to="", bcc="", subject="", plaintext=""): """ Send an email via Postmark. Used when the application is deployed on Heroku. Note: The Postmark team has chosen not to continue development of the Heroku add-on as of June 30, 2017. Newspipe is now using SendGrid when deployed on Heroku. """ from postmark import PMMail try: message = PMMail(api_key = conf.POSTMARK_API_KEY, subject = subject, sender = conf.NOTIFICATION_EMAIL, text_body = plaintext) message.to = to if bcc != "": message.bcc = bcc message.send() except Exception as e: logger.exception('send_postmark raised:') raise e