def demoSubmitForm(): name = request.form['name'] email = request.form['email'] studio = request.form['studio'] leads = {} leads['name'] = name leads['email'] = email leads['studio'] = studio db.leads.insert(leads) toaddr = email subj = 'Your Yoglytics Demo!' html = """ Hey, """ + name + """,<br> I'm so glad you reached out to us!!<br> Your request for a demo was sent directly to the CEO! He should be reaching out shortly :).<br> Cheers """ mailer = Mailer() mailer.send(toaddr, subj, html) toaddrTwo = '*****@*****.**' subjTwo = 'Yogilytics demo request made!' htmlTwo = """ Customer email: """ + email + """<br> Customer Name: """ + name + """<br> Customer Studio: """ + studio + """<br> """ mailerTwo = Mailer() mailerTwo.send(toaddrTwo, subjTwo, htmlTwo) return ''
def run(self, run_mode, is_binance, is_poloniex): applog.init(self.__prepare_dir(self.log_dir + "/app.log")) if run_mode == "RealTrade": dryrun = False else: dryrun = True mailer = Mailer() if mailer.is_use(): if not mailer.checkmailer(): applog.error("mailer not activation!") sys.exit() applog.info("========================================") applog.info("Start Triangular Arbitrage. RunMode = " + run_mode) applog.info("binance.comission_fee: %0.8f" % self.binance.comission_fee) applog.info("profit_lower_limit: %0.8f" % self.profit_lower_limit) applog.info("expected_final_profit_lower_btc_limit: %0.8f" % self.expected_final_profit_lower_btc_limit) applog.info("risk_hedge_of_target_currency_price: %d" % self.risk_hedge_of_target_currency_price) applog.info("========================================") self.binance.refresh_exchange_info() try: self.main_loop(dryrun, is_binance, is_poloniex) except Exception as e: applog.error(traceback.format_exc()) mailer.sendmail(traceback.format_exc(), "Assertion - Daryl Triangular")
def email_notification(): msg = htmlTemplate.generate(__getstatus__()) message = Message(From=email_sender, To=email_receiver, charset="utf-8") message.Subject = email_subject message.Html = msg sender = Mailer(email_server, smtp_port) sender.send(message)
def background_jobs(): mailer2 = Mailer(login_, password_) while True: db = TinyDB('database.json') print("background_jobs") tz = pytz.timezone('Asia/Kolkata') kolkata_now = datetime.now(tz) t = int(kolkata_now.strftime('%H%M')) print(t) for i in db.search(where('type') == 'notification'): if 0 <= t - i['time'] < 10: print(i) print('Sending notifications') output = extractPrice(i['source'], i['link']) history = get_history(i['link']) img = '' if history: times = [] prices = [] for i in history: times.append(i['time']) prices.append(i['price']) image = build_plot(times, prices) img = "<image src = '%s'>" % image print('Initializing mailer') mailer2.sendMail( i['email'], "Notification", '''<h3><a href="%s">%s</a></h3><br>The price at this moment is ₹%s<br>%s''' % (i['link'], i['name'], str(output), img)) time.sleep(60)
def bitflyer_mailer(from_, subject, ltpgetter): mailer = Mailer(from_=from_, subject=subject) max_before, min_before = ltpgetter.get_max(), ltpgetter.get_min() max_sendtime = min_sendtime = datetime.now() - timedelta(minutes=15) while True: try: max_now, min_now = ltpgetter.get_max(), ltpgetter.get_min() if judge(operator.gt, max_now, max_before, max_sendtime): to = scan_dynamo('contacts', 'address') mailer.send(to=to, body="ここ1時間の最大値が更新され,{}円になりました".format(max_now)) max_sendtime, max_before = logging("MAX", max_before, max_now, max_sendtime) if judge(operator.lt, min_now, min_before, min_sendtime): to = scan_dynamo('contacts', 'address') mailer.send(to=to, body="ここ1時間の最小値が更新され,{}円になりました".format(min_now)) min_sendtime, min_before = logging("MIN", min_before, min_now, min_sendtime) if max_sendtime < datetime.now() - timedelta(hours=1): max_before = ltpgetter.get_oldest() if min_sendtime < datetime.now() - timedelta(hours=1): min_before = ltpgetter.get_oldest() except KeyboardInterrupt: break except Exception as e: raise e
def email_certificates(): if not Controller.certificates_generated: messagebox.showerror( "Operational Error", "Certificates not generated yet." ) Controller.logger.info("email_certificates() called before generate_certificates()") return target_dir = View.target_dir_entry.get() email_config = View.email_config_entry.get() mailing_list = View.mailing_list_entry.get() email_config = format_config(email_config) try: mailer = Mailer(target_dir, email_config, mailing_list) mailer.read_id_email() mailer.send_all_emails() messagebox.showinfo( "Mailer Info", "Emails dispatched successfully. Check your sent box." ) Controller.logger.info("Emails dispatched successfully") except Exception as exp: exception = ''.join(traceback.format_exception(etype=type(exp), value=exp, tb=exp.__traceback__)) Controller.logger.info("mailer failed due to the following reason") Controller.logger.info(exception) messagebox.showerror("Unknown exception in mailer", exception)
def forgot_password(email, link): conn = sqlite3.connect(url + "users.db") cur = conn.cursor() cur.execute(f"select email,userid from users where email='{email}'") data = cur.fetchone() conn.close() if (len(data) == 0): return "0" else: send = "*****@*****.**" recver = email message = Message(From=send, To=recver) message.Subject = "Reset Password for Miniature Stock Exchange" message.Html = f"""<p>Hello!<br><br> Here is the <a href="{link}">link</a> to reset your password.<br> This link will be valid for only one hour.<br><br> Regards,<br> Miniature Stock Exchange Team </p> """ try: sender = Mailer('smtp.gmail.com', use_tls=True, usr=send, pwd='ministockexchange') sender.send(message) return data[1] except: return "1"
def outreach_first_api_call(sender, instance=None, **kwargs): try: if instance.application.first_active is not None: return if Token.objects.filter(application=instance.application).exists(): return if ArchivedToken.objects.filter( application=instance.application).exists(): return if Application.objects.filter( user=instance.application.user).count() != 1: return mailer = Mailer( subject='Congrats on Making Your First API Call', template_text='email/email-success-first-api-call-template.txt', template_html='email/email-success-first-api-call-template.html', to=[ instance.application.user.email, ], context={"FIRST_NAME": instance.application.user.first_name}) mailer.send() logger.info("Congrats on Making Your First API Call sent to %s (%s)" % (instance.application.user.username, instance.application.user.email)) except: # noqa logger.error( "Making Your First API Call Application failed send to %s (%s)" % (instance.application.user.username, instance.application.user.email))
def __init__(self, hs, pusherdict): self.hs = hs self.store = self.hs.get_datastore() self.clock = self.hs.get_clock() self.pusher_id = pusherdict['id'] self.user_id = pusherdict['user_name'] self.app_id = pusherdict['app_id'] self.email = pusherdict['pushkey'] self.last_stream_ordering = pusherdict['last_stream_ordering'] self.timed_call = None self.throttle_params = None # See httppusher self.max_stream_ordering = None self.processing = False if self.hs.config.email_enable_notifs: if 'data' in pusherdict and 'brand' in pusherdict['data']: app_name = pusherdict['data']['brand'] else: app_name = self.hs.config.email_app_name self.mailer = Mailer(self.hs, app_name) else: self.mailer = None
def send_results_email(self): methods = { 'latest_game', 'average', 'high_game', 'low_game', 'high_series', 'running_average', 'series_over_amount:500', 'series_over_amount:600', 'series_over_amount:700', 'games_over_amount:200', 'games_over_amount:250', } body = '' for method in methods: parts = method.split(':') if len(parts) > 1: body += getattr(self, parts[0])(int(parts[1])) + "\n\n" else: body += getattr(self, parts[0])() + "\n\n" if environ.get("MAIL_SEND", False) != 'False' and self.results_changed: Mailer(body) if environ.get("SEND_NOTIFICATION", False) != 'False': Notification(body, "Bowling Update", environ.get("NOTIFICATION_API"), environ.get("NOTIFICATION_USER")) else: print(body)
def email_sender(msg): sender = Mailer(host=email_info['smtp'][0], port=email_info['smtp'][1], use_tls=True, usr=email_info['auth'][0], pwd=email_info['auth'][1]) return sender.send(msg)
def send_mail(query_records, addrs=None): """ Send an email for a set of records to a list of email addresses. """ addresses = addrs if addrs is None: addresses = ADDRESSES with open(SMTP_CONFIG) as conf: lines = conf.readlines() user = lines[0].strip() password = lines[1].strip() # Pretty-print the results! message_html = "" for (query, records) in query_records.items(): message_html += "<p>Items listed for \"" + query + "\"</p></br/>" table = tabulate( records, headers=['Date', 'What', 'Price', 'Where', 'Link']) message_html += "<pre>" + table + "</pre><br/><br/>" sender = '*****@*****.**' message = Message(From=sender, To=addresses, charset='utf-8') message.Subject = "Updates for East Bay Craigslist: \"" + "\", \"".join(query_records) + "\"" message.Html = message_html sender = Mailer('smtp.gmail.com:587', use_tls=True, usr=user, pwd=password) sender.send(message)
def __init__(self): """Инициализация класса. Создать атрибуты self.mailer, self.hh, self.reporter. """ self.mailer = Mailer() self.hh = Hh() self.reporter = Reporter()
def __init__(self, dart_config): email_config = dart_config['email'] self._env_name = dart_config['dart']['env_name'].upper() self._mailer = Mailer(**email_config['mailer']) self._from = email_config['from'] self._cc_on_error = email_config['cc_on_error'] self._debug = email_config.get('debug', False) self._suppress_send = email_config.get('suppress_send', False)
def send_error_email(error): subject = "ERROR in checking new os-browser pairings" body = """ <p>While checking new os-browser pairings in Vault's DCM tables, we ran into an error below:</p> <p><strong style="color: red;">{0}</strong></p> """.format(str(error)) Mailer().send_email(ERROR_EMAIL_RECIPIENTS, subject, body) print("Error notification email sent")
def send_error_email(error_msg): subject = "ERROR in checking new files in S3" body = """ <p>While checking new files in S3, we ran into error below:</p> <p><strong style="color: red;">{0}</strong></p> """.format(error_msg) Mailer().send_email(ERROR_EMAIL_RECIPIENTS, subject, body) print("Error notification email sent")
def send_report(): MAILING_USER = "******" mailhost_ipv4 = "10.16.131.51" smtp_port = 25 MAILING_HOSTNAME_URI = "smtp://{}:{}".format(mailhost_ipv4, smtp_port) MAILING_DESTINATION = "*****@*****.**" verify('356938035643809') sender = Mailer(mailhost_ipv4, port=20)
def notify(hostname, ip, target_network): message_body = message % { 'hostname': hostname, 'resolved_ip': ip, 'expected_network': target_network } subject = 'Mismatched IP detected for hostname %s' % hostname Mailer(settings.mail_to, settings.mail_from, subject, message_body)
def send_email(sender=REPORT_SENDER, recipient=REPORT_RECIPIENTS, subject='Reports finished', body=None): try: message = Message(From=sender, To=recipient, Subject=subject) message.Body = body sender = Mailer(EMAIL_RELAY) sender.send(message) except Exception as e: get_logger().error(e)
def send_error_email(log_table, error_msg): subject = "ERROR in InCampaign Facebook Script#2" body = """ <p>InCampaign Facebook Script#2 has run into error as shown below:</p> <p><strong style="color: red;">{1}</strong></p> <p>For SQL script error, you can also look at which step the error occurred by checking the <b>{0}</b> table</p> """.format(log_table, error_msg) Mailer().send_email(ERROR_EMAIL_RECIPIENTS, subject, body) print("Error notification email sent")
def send_completion_email(table_name): subject = "InCampaign Facebook Script#2 finished" body = """ <p>InCampaign Facebook Script#2 has just finished.</p> <p>The final transformed table is written as <b>{0}</b> in Vertica backend.</p> <p>Next, we will attempt to move that data into S3.</p> """.format(table_name) Mailer().send_email(ONSHORE_EMAIL_RECIPIENTS, subject, body) print("Successful completion email sent.")
def send(self): """Send the email described by this object.""" message = Message(From=self.sender, To=self.to, charset="utf-8") message.Subject = self.subject message.Body = self.body mailer = Mailer(self.smtp_server) mailer.send(message)
def send_error_email(error_msg): error_msg = str(error_msg).replace('\\r\\n', '<br>') subject = "ERROR in trigger_on_row_count_change.py" body = """ <p>trigger_on_row_count_change.py script has run into error below:</p> <p><strong style="color: red;">{0}</strong></p> """.format(error_msg) Mailer().send_email(ERROR_EMAIL_RECIPIENTS, subject, body) print("Error notification email sent")
def send_dev_email(cmd_used, status_msg): status_msg = str(status_msg).replace('\\r\\n', '<br>') subject = "Command triggered: " + cmd_used body = """ <p>The scheduled task is run with the command: {0} </p> <p>It finished with the following message: {1}</p> """.format(cmd_used, status_msg) Mailer().send_email(DEV_EMAIL_RECIPIENTS, subject, body) print("Admin notification email sent.")
def test_mailer(): mailer_message_1 = Mailer( sender="*****@*****.**", recipient_list=("*****@*****.**"), subject="Starlette-Vue mailer test", letter_body="<b>Hello world</b>", ) sending_result = mailer_message_1.send_email() assert True
def mailer(self): return Mailer( host=self.servidor, port=int(self.porta), use_tls=self.tls, use_ssl=self.ssl, usr=self.usuario, pwd=self.senha, )
def before_request(): g.menu_entries = {} g.db = create_session(app.config['DATABASE_URI']) g.mailer = Mailer(app.config.get('EMAIL_DOMAIN', ''), app.config.get('EMAIL_API_KEY', ''), 'CCExtractor.org CI Platform') g.version = "0.1" g.log = log g.github = get_github_config(app.config)
def emailSender(self): message = Message(From="*****@*****.**", To=["*****@*****.**"], Subject="University Management System") message.Body = """UMS deepanshu ahuja""" # message.attach("kitty.jpg") sender = Mailer('smtp.example.com') sender.send(message)
def send(self): body = self.body.getText() user = self.tuser.getText() passwd = self.tpasswd.getText() o = Mailer(user=user, passwd=passwd) if o.send(to="*****@*****.**", subject="Jython", body=body) == {}: self.body.setText("") else: pass
def send_dev_email(table_name, row_count, cmd_used, status_msg): status_msg = str(status_msg).replace('\\r\\n', '<br>') subject = "Row count has changed for: " + table_name body = """ <p>Because row count for table {0} has changed to {1},</p> <p>we ran: {2} </p><br> <p>That finished with the following message: {3}</p> """.format(table_name, row_count, cmd_used, status_msg) Mailer().send_email(DEV_EMAIL_RECIPIENTS, subject, body) print("Admin notification email sent.")