def partners_interest(name, company_name, email, website, note): if not re.match(r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)", email): return gettext('Please enter a valid email address') if website and not re.match( r"(^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$)", website): return gettext('Please enter a valid website address') try: me = db_models.Interest() me.name = name me.company_name = company_name me.email = email me.website = website me.note = note db.session.add(me) db.session.commit() except Exception as e: print(e) return gettext('Ooops! Something went wrong.') message = "Name: %s<br>Company Name: %s<br>Email: %s<br>Website: %s<br>Note: %s" % ( name, company_name, email, website, note) email_types.send_email_type('build_on_origin', DEFAULT_SENDER, email) sgw.notify_admins( message, subject="{name} ({company_name}) is interested in building on Origin". format(name=name, company_name=company_name)) return gettext('Thanks! We\'ll be in touch soon.')
def send_email_msg(from_email, to_email, msg_subject, msg_purpose, msg_text, msg_html): if not has_existing_message(to_email, msg_purpose): try: add_to_message_log(to_email, msg_purpose, msg_text, msg_subject, msg_html) try: categories = [msg_purpose] if 'localhost' in constants.HOST or 'pagekite' in constants.HOST: sgw.send_message( sender=from_email, recipients=[sgw.Email(constants.DEV_EMAIL, constants.DEV_EMAIL)], subject='DEV: ' + msg_subject, body_text=msg_text, body_html=msg_html, categories=categories) else: sgw.send_message( sender=from_email, recipients=[sgw.Email(to_email, to_email)], subject=msg_subject, body_text=msg_text, body_html=msg_html, bccs=BCC_RECIPIENTS, categories=categories) except Exception as e: sgw.notify_admins("Unable to send email message for " + to_email + " because \n\n" + str(e)) except Exception as e: sgw.notify_admins("Unable to write to message log for " + to_email + " because \n\n" + str(e))
def send_email_msg(from_email, to_email, msg_subject, msg_category, msg_text, msg_html): try: categories = [msg_category] if 'localhost' in constants.HOST or 'pagekite' in constants.HOST: sgw.send_message(sender=from_email, recipients=[ sgw.Email(constants.DEV_EMAIL, constants.DEV_EMAIL) ], subject='DEV: ' + msg_subject, body_text=msg_text, body_html=msg_html, categories=categories) else: sgw.send_message(sender=from_email, recipients=[to_email], subject=msg_subject, body_text=msg_text, body_html=msg_html, bccs=BCC_RECIPIENTS, categories=categories) except Exception as e: sgw.notify_admins("Unable to send email message to " + to_email.email + " because \n\n" + str(e))
def presale(full_name, email, accredited, entity_type, desired_allocation, desired_allocation_currency, citizenship, sending_addr, note, ip_address): if not re.match(r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)", email): return gettext('Please enter a valid email address') try: me = db_models.Presale() me.full_name = full_name me.email = email me.accredited = (accredited == '1') me.entity_type = entity_type me.desired_allocation = desired_allocation me.desired_allocation_currency = desired_allocation_currency me.citizenship = citizenship me.sending_addr = sending_addr me.note = note db.session.add(me) db.session.commit() except Exception as e: print(e) return gettext('Ooops! Something went wrong.') if sending_addr: sending_addr = "<a href='https://etherscan.io/address/" + sending_addr + "'>" + sending_addr + "</a>" if sending_addr.startswith( '0x' ) else "<a href='https://blockchain.info/address/" + sending_addr + "'>" + sending_addr + "</a>" message = """Name: %s<br> Email: %s<br> Accredited: %s<br> Entity: %s<br> Desired allocation: %s %s<br> Citizenship: %s<br> Address: %s<br> Note: %s<br> IP: %s""" % (full_name, email, ("Yes" if accredited == "1" else "No"), entity_type, desired_allocation, desired_allocation_currency, citizenship, sending_addr, note, ip_address) email_types.send_email_type('presale', DEFAULT_SENDER, email) sgw.notify_admins(message, subject=full_name + " is interested in the presale") return gettext('Thanks! We\'ll be in touch soon.')
from tools import db_utils from util import sendgrid_wrapper as sgw from logic.emails import email_types # this is called daily using a Heroku cron job if __name__ == '__main__': with db_utils.request_context(): try: email_types.send_welcome_drips() except Exception as e: print(e) sgw.notify_admins("Error sending welcome drips %s" % (e), "Error sending welcome drips")