Exemple #1
0
def send_email(user_email="", html="", subject=""):
    msg = Message(From="Cool App", To=user_email, charset="utf-8")
    msg.Subject = subject
    msg.Body = subject
    msg.Html = html

    return email_sender(msg)
    def send(self, from_address, to_address, subject, body=None, html=True):
        try:
            message = Message(
                From=from_address,
                To=to_address,
                charset=self.charset
            )

            if body is None:
                body = ''
            self.body = body

            message.Subject = "%s - %s" % (self.subject_prefix, subject)
            message.Html = self.body
            message.Body = self.body
        except Exception as e:
            log.exception('[scaffold_mailer] - Failed to create message object for mailer')
            return False

        try:
            sender = Mailer(
                host=self.config.get('host'),
                port=self.config.get('port'),
                use_tls=self.config.get('use_tls', False),
                use_ssl=True,
                usr=self.config.get('username'),
                pwd=self.config.get('password'))
            sender.send(message)
        except Exception as e:
            log.exception('[scaffold_mailer] - Failed to connect to smtp sever and send message with subject: %s' % message.Subject)
            return False
        return True
Exemple #3
0
 def send_contact_email(self, request):
     try:
         data = json.loads(request.data.decode())
         first_name = data["first_name"]
         last_name = data["last_name"]
         email = data["email"]
         content = data["content"]
         if re.search(r'[\w.-]+@[\w.-]+.\w+', email):
             message = Message(From=self.email, To="Support-Codex-Contact")
             message.Subject = "Feedback " + first_name
             message.Html = """<p>Stock Prediction!<br>"""+\
             """<br>"""+"Name : "+first_name +" "+last_name+"""<br>"""+ \
             """<br>""" + "Email : " + email + """<br><br><br> """ + \
                            content
             server = smtplib.SMTP('smtp.gmail.com', 587)
             server.ehlo()
             server.starttls()
             server.ehlo()
             server.login(self.email, self.password)
             server.sendmail(self.email, self.email, message.as_string())
             return {"status": "True"}
         else:
             return {"msg": "invalid email", "status": "False"}
     except Exception as e:
         generate_log('get_user_profile', str(e), str(request))
Exemple #4
0
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"
Exemple #5
0
def notify(args):
    config = parse_config(args.config)  
    db = database.WatchDb(db_path=DB_PATH)
    LOGGER.info("Notify if something is not working...")
    if db.get_status(config['notify']['track_last']):
        LOGGER.info("Everything seems to be ok.")
    else:
        LOGGER.warning("One of tests failed, generate report.")
        env = Environment(loader=FileSystemLoader(DIRECTORY))
        template = env.get_template('template.html')
        body = template.render(table=db.get_latest(config['notify']['track_last']))
        LOGGER.info("Sending email...")
        sender = Mailer(
            config['smtp']['host'],
            port=config['smtp']['port'],
            usr=config['smtp']['user'],
            pwd=config['smtp']['password'],
        )
        message = Message(
            From=config['smtp']['user'],
            To=config['notify']['email'],
        )
        message.Subject = config['notify']['subject']
        message.Html = body
        sender.send(message)
Exemple #6
0
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)
Exemple #7
0
def send_email(user, pwd, recipient, subject, body):

    gmail_user = user
    gmail_pwd = pwd
    FROM = user
    TO = recipient if type(recipient) is list else [recipient]
    SUBJECT = subject
    TEXT = body

    message = Message(From=user, To=recipient)
    message.Subject = subject
    message.Html = body

    # Prepare actual message
    #message = """From: %s\nTo: %s\nSubject: %s\n\n%s
    #""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
    #print(message)
    try:
        server = smtplib.SMTP("smtp.gmail.com", 587)
        server.ehlo()
        server.starttls()
        print("tls started")
        server.login(gmail_user, gmail_pwd)
        print("log in succesfull")
        server.sendmail(FROM, TO, message.as_string())
        print('successfully sent the mail')
        server.close()
        print("server closed")
    except smtplib.SMTPException as error:
        print(str(error))
        print("fail")
Exemple #8
0
def getMessage(emailAddress):
    message = Message(From=username, To=emailAddress, charset="utf-8")

    numOfSpamMail = execSelectSql(
        "SELECT COUNT(idSpamMail) FROM SpamMail")[0][0]
    randMailIndex = int(random.random() * numOfSpamMail)

    spamMail = execSelectSql(
        "SELECT idEmail, repo FROM SpamMail")[randMailIndex]

    idEmail = spamMail[0]
    repo = spamMail[1]

    urlResponse = urllib.request.urlopen(
        str(repo) + "/" + str(idEmail) + "/mail.txt")
    spamMessageContent = urlResponse.read()
    spamMessageText = spamMessageContent.decode(
        urlResponse.headers.get_content_charset('utf-8')).replace(
            '\n', '<br>')
    spamMessageText = processRepoText(spamMessageText, idEmail, repo,
                                      emailAddress)

    urlResponse = urllib.request.urlopen(
        str(spamMail[1]) + "/" + str(spamMail[0]) + "/subject.txt")
    spamMessageSubjectText = urlResponse.read()
    spamMessageSubject = spamMessageSubjectText.decode(
        urlResponse.headers.get_content_charset('utf-8'))

    message.Subject = (spamMessageSubject)
    message.Html = spamMessageText

    # increment database
    incrementSentNumber(idEmail)

    return message
Exemple #9
0
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)
Exemple #10
0
def send_email(user, pwd, recipient, subject, body):

    gmail_user = user
    gmail_pwd = pwd
    FROM = user
    TO = recipient if type(recipient) is list else [recipient]
    SUBJECT = subject
    TEXT = body

    message = Message(From=FROM,
                      To=TO)

    message.Subject = SUBJECT
    message.Html = """
                        <html>
                          <head></head>
                          <body>
                            <p>Hi! You've requested the UTNC practice schedule<br>
                               How are you?<br>
                               Here is the <a href="http://www.python.org">link</a> you wanted.
                            </p>
                          </body>
                        </html>
                        """

    sender = Mailer('smtp.gmail.com',port=587, use_tls=True, usr=gmail_user, pwd=gmail_pwd)
    sender.send(message)
Exemple #11
0
 def mail_manifest(self, emailfrom, emailto):
     message = Message(From=emailfrom, To=emailto)
     message.Subject = "Manifest"
     message.Html = self.fetch_manifest()
     
     sender = Mailer('localhost')
     sender.send(message)
Exemple #12
0
 def send_reset_email(self):
     self.token = os.urandom(32).encode('hex')
     sender = Mailer('localhost', port=25)
     msg = Message(From="*****@*****.**", To=[self.email],
                   charset="utf-8")
     msg.Subject = u'Accès trombinoscope ACR'
     msg.Body = _BODY % (unicode(self.token), unicode(self.login))
     sender.send([msg])
Exemple #13
0
def send_email_with_file(user_email="", html="", subject="", file_path=""):
    msg = Message(From="Cool App", To=user_email, charset="utf-8")
    msg.Subject = subject
    msg.Body = subject
    msg.Html = html
    msg.attach(file_path)

    return email_sender(msg)
 def _send(self, subject, htmlbody, textbody):
     for to in config().backupmailrecipients:
         logger().info("Sent backup report to [%s] via SMTP:%s" % (to, config().smtphost))
         message = Message(From=config().backupmailfrom, To=to, charset="utf-8")
         message.Subject = subject
         message.Html = htmlbody
         message.Body = textbody
         sender = Mailer(config().smtphost)
         sender.send(message)
Exemple #15
0
def send_email(msg):
    from mailer import Mailer, Message
    mail_msg = Message(From="监听者<%s>"%(os.environ["MAIL_ADDR"]),
                    To=["*****@*****.**"],
                    charset="utf-8")
    mail_msg.Subject = "Watchpmc Report"
    mail_msg.Html = msg
    sender = Mailer(host="smtp.yeah.net", usr=os.environ["MAIL_ADDR"], pwd=os.environ["MAIL_PASS"])
    sender.send(mail_msg)
Exemple #16
0
 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)
Exemple #17
0
 def _send(self, subject, htmlbody):
     for to in config().backupmailrecipients:
         logger().info("INFO: Sent backup report to [%s] via SMTP:%s" % (to, config().smtphost))
         message = Message(From=config().backupmailfrom, To=to, charset="utf-8")
         message.Subject = subject
         message.Html = htmlbody
         message.Body = """This is an HTML e-mail with the backup overview, please use a HTML enabled e-mail client."""
         sender = Mailer(config().smtphost)
         sender.send(message)
def sendEmail(toaddr, ccs, bccs, body, subject):
	""" 'sendEmail()' is called by 'feedConsumer()' when it is ready to
	send the e-mail to the specified recipient using SMTP; in case of
	failure to send, fallback gracefully to using the existing
	[email protected] account."""
	mailer = Mailer('smtp.gmail.com', port=587, use_tls=True, usr="******", pwd="mailerbot")
	msg = Message(From="*****@*****.**", To=toaddr, CC=ccs, BCC=bccs, Body=body)
	msg.Subject = subject
	mailer.send(msg)
Exemple #19
0
def verify_email(user):
#     logger.debug("Generated email verification link: " + user.reg_id)
#     if not user.active:
    message = Message(From="*****@*****.**",To="*****@*****.**",charset="utf-8")
    message.Subject = "Flotag Email Verification"
    message.Html = """This email uses <strong>Complete Flotag Registration</strong>!"""
    message.Body = """Flotag Registration"""
    
    sender = Mailer('127.0.0.1')
    sender.send(message)
Exemple #20
0
def send_btc_mail(subjectstring, messagestring):
    message = Message(From=settings.MAILSENDER,
                      To=settings.TOLIST,
                      charset="utf-8")
    message.Subject = subjectstring
    message.Html = messagestring
    mysender = Mailer(host=settings.MAILHOST,
                      pwd=settings.MAILPWD,
                      usr=settings.MAILSENDER)
    mysender.send(message)
Exemple #21
0
 def handle_notification(self, users, subject, body):
     "Send a notification email."
     recipients = [u.email for u in users if u.email is not None]
     if len(recipients) > 0:
         msg = Message(From=config.get('mailer.from', 'root@localhost'),
                       To=recipients,
                       charset='utf-8')
         msg.Subject = ("BlueChips: %s" % subject).encode('utf-8')
         msg.Body = body
         self.send_message(msg)
Exemple #22
0
def sendMail(item, hwp):
    sender = Mailer('smtp.gmail.com', use_tls=True)
    for to in MAILER_TO:
        sender.login(MAILER_USERNAME, MAILER_PASSWORD)
        message = Message(From='*****@*****.**', To=to)
        message.Subject = "가정통신문 :%s" % item['title'].encode('utf-8')
        message.Html = ""
        if hwp:
            message.attach(hwp)
        sender.send(message)
Exemple #23
0
    def send(self, from_address, to_address, subject, body='', html=True):
        message = Message(From="*****@*****.**",
                          To=to_address,
                          charset=self.charset)
        message.Subject = "%sAn HTML Email" % self.subject_prefix
        message.Html = body
        message.Body = body

        sender = Mailer(self.host)
        sender.send(message)
Exemple #24
0
def sendMail(item, hwp):
    sender = Mailer('smtp.gmail.com',use_tls=True)
    for to in MAILER_TO :
        sender.login(MAILER_USERNAME,MAILER_PASSWORD)
        message = Message(From='*****@*****.**', To=to)
        message.Subject = "가정통신문 :%s"%item['title'].encode('utf-8')
        message.Html = ""
        if hwp:
            message.attach(hwp)
        sender.send(message)
Exemple #25
0
 def handle_notification(self, users, subject, body):
     "Send a notification email."
     recipients = [u.email for u in users if u.email is not None]
     if len(recipients) > 0:
         msg = Message(From=config.get('mailer.from',
                                       'root@localhost'),
                       To=recipients)
         msg.Subject = "BlueChips: %s" % subject
         msg.Body = body
         self.send_message(msg)
Exemple #26
0
def send(url, email):
    """Sends a html page to an email. Requires a local smtp server and the mailer module"""
    html = urllib2.urlopen(url).read()
    
    mail = Message(From = "test", To = email, charset='UTF-8')
                   
    mail.Subject = "Test email"
    mail.Html = html
    
    sender = Mailer()
    sender.send(mail)
Exemple #27
0
def build_message(email):
    message = Message()
    message.To = email
    message.From = "icloud-drive-docker <" + email + ">"
    message.Date = datetime.datetime.now().strftime("%d/%m/%Y %H:%M")
    message.Subject = "icloud-drive-docker: Two step authentication required"
    message.Body = """Two-step authentication for iCloud Drive (Docker) is required.
Please login to your server and authenticate.  Eg:
`docker exec -it icloud-drive /bin/sh -c "icloud --username=<icloud-username>"`."""

    return message
Exemple #28
0
    def send_email(self):
        try:
            message = self.message
            message = Message(From="localhost", To="*****@*****.**")
            message.Subject = "An HTML Email"
            message.Html = """<p>Hello!<br>The pipeline has failed Fix this and rerun it again message</p>"""
            sender = Mailer('localhost')
            sender.send(message)

        except TestFailed as message:
            print(message)
def send_email(from_email, to_email_list, subject, html, smtp_host, smtp_port=587, username=None, password=None):
    message = Message(From=from_email, To=to_email_list, charset='utf-8')
    # Keep from creating threads in gmail...
    message.Subject = "{} -- {}".format(subject, datetime.now().strftime('%Y-%m-%dT%H:%M:%S'))
    message.Html = html.encode('utf-8')
    message.Body = 'See the HTML!'

    sender = Mailer(host=smtp_host, port=smtp_port, use_tls=True, usr=username, pwd=password)
    if username is not None:
        sender.login(username, password)
    sender.send(message)
Exemple #30
0
def send_email(image):
    # Format email message
    message = Message(From=MAIL_FROM, To=MAIL_TO)
    message.Subject = MAIL_SUBJECT
    message.Html = MAIL_HTML
    message.Body = MAIL_BODY
    message.attach(image)

    # Send message to SMTP server
    sender = Mailer(SMTP_HOST)
    sender.send(message)
def send_mail(subject, contents, host, use_ssl, sender, pwd, email_address):
    message = Message(From=sender,
                      To=email_address, charset="utf-8")
    message.Subject = subject
    message.Html = contents
    sender = Mailer(host=host, use_ssl=use_ssl, usr=sender[:sender.find("@")],
                    pwd=pwd)

    sender.send(message, debug=False)

    log.info("sender:%s,to=%s" % (sender, email_address))
def sendEmailTest():
    from mailer import Mailer
    from mailer import Message

    message = Message(From="*****@*****.**", To="*****@*****.**")
    message.Subject = "An HTML Email"
    message.Html = """<p>Hi!<br>
		How are you?<br>
		Here is the <a href="http://172.16.2.249/kpi-android-cn.html">link</a>you wanted.</p>"""
    sender = Mailer("mail.bainainfo.com")
    sender.send(message)
Exemple #33
0
def main():
    rev = test_rev.get_rev('./')

    message = Message(From="*****@*****.**",
                      To="*****@*****.**",
                      charset="utf-8")
    message.Subject = "HYMLS test results for revision " + rev
    message.Body = dataparser.compare(rev)

    sender = Mailer('smtp.rug.nl')
    sender.send(message)
Exemple #34
0
def send_email(image):
	# Format email message
	message = Message(From=MAIL_FROM,To=MAIL_TO)
	message.Subject = MAIL_SUBJECT
	message.Html = MAIL_HTML
	message.Body = MAIL_BODY
	message.attach(image)

	# Send message to SMTP server
	sender = Mailer(SMTP_HOST)
	sender.send(message)
Exemple #35
0
def verify_email(user):
    #     logger.debug("Generated email verification link: " + user.reg_id)
    #     if not user.active:
    message = Message(From="*****@*****.**",
                      To="*****@*****.**",
                      charset="utf-8")
    message.Subject = "Flotag Email Verification"
    message.Html = """This email uses <strong>Complete Flotag Registration</strong>!"""
    message.Body = """Flotag Registration"""

    sender = Mailer('127.0.0.1')
    sender.send(message)
Exemple #36
0
 def _send(self, subject, htmlbody):
     for to in config().backupmailrecipients:
         logger().info("Sent backup report to [%s] via SMTP:%s" %
                       (to, config().smtphost))
         message = Message(From=config().backupmailfrom,
                           To=to,
                           charset="utf-8")
         message.Subject = subject
         message.Html = htmlbody
         message.Body = """This is an HTML e-mail with the backup overview, please use a HTML enabled e-mail client."""
         sender = Mailer(config().smtphost)
         sender.send(message)
 def _send(self, subject, htmlbody, textbody):
     for to in config().backupmailrecipients:
         logger().info("Sent backup report to [%s] via SMTP:%s" %
                       (to, config().smtphost))
         message = Message(From=config().backupmailfrom,
                           To=to,
                           charset="utf-8")
         message.Subject = subject
         message.Html = htmlbody
         message.Body = textbody
         sender = Mailer(config().smtphost)
         sender.send(message)
Exemple #38
0
    def send_feedback_mail(version, username, feedback, logcat):
        # noinspection PyBroadException
        try:
            msg = Message(From=args.user, To=args.receiver, charset="utf8")
            msg.Subject = u"Feedback {} ({})".format(version, username)
            msg.Body = u"User: {0} http://pr0gramm.com/user/{0}\nFeedback: {1}\n\nLogcat: {2}\n".format(username, feedback, logcat)

            mailer = Mailer(args.host, port=587, use_tls=True, usr=args.user, pwd=args.password)
            mailer.send(msg)

        except:
            traceback.print_exc()
Exemple #39
0
    def flush(self):
        root = ET.Element("html")

        for flat in self.flats_buffer:
            flat_dict = flat.to_dict()
            self._display_to_html(flat_dict, root)

        message = Message(From="*****@*****.**",
                          To="*****@*****.**")
        message.Subject = f"MIESZKANIA"
        message.Html = ET.tostring(root, method='html')
        self.mailer.send(message)
Exemple #40
0
 def send_auth_email(email, auth_url):
     logger.info("Login here to use Spotify API: %s", auth_url)
     mailer = Mailer(**config.email)
     # pylint: disable=no-member
     html_content = LOGIN_HTML.read_text().replace(
         "SPOTIFY_AUTHENTICATION_URL", auth_url
     )
     message = Message(From=config.email.usr or email, To=email, charset="utf-8")
     message.Subject = "Spotify API Authentication"
     message.Html = html_content
     message.Body = f"Login here to use Spotify API: {auth_url}"
     mailer.send(message)
Exemple #41
0
def SendMail(MailConfig, Content, filename=None):
    message = Message(From=MailConfig.SENDOR,
                      To=MailConfig.RECEIEVERS,
                      charset="utf-8")
    message.Subject = MailConfig.SUBJECT
    message.Html = Content
    if filename != None:
        message.attach(filename)
    server = smtplib.SMTP(MailConfig.SMTPSETTING)
    server.starttls()
    server.sendmail(MailConfig.SENDOR, MailConfig.RECEIEVERS.split(";"),
                    message.as_string())
    server.quit()
Exemple #42
0
    def insert(self, values):
        """When an INSERT statement is set, send a mail with the 
            from, to, subject, html_body and body values."""
        message = Message(From=values["from"],
                          To=values["to"],
                          charset="utf-8")
        message.Subject = values["subject"]

        message.Html = values["html_body"] or None
        message.Body = values["body"]

        sender = Mailer('localhost')
        sender.send(message)
Exemple #43
0
def send_mail(body, recipient, subject):
    message = Message(From="*****@*****.**",
                      To=recipients[recipient],
                      charset="utf-8")
    message.Subject = subject
    message.Html = body

    try:
        sender = Mailer('mail.chubb.com')
        sender.send(message)
        return True
    except Exception as ex:
        return False
Exemple #44
0
def sendVerificationMail(user, address, code):
    # send message
    message = Message(From="\"Galaxy Harvester Activation\" <{0}>".format(
        mailInfo.REGMAIL_USER),
                      To=address)
    message.Subject = "Galaxy Harvester Account Verification"
    link = "http://galaxyharvester.net/verifyUser.py?vc={0}".format(code)
    message.Body = "Hello " + user + ",\n\nYou have created a new account on galaxyharvester.net using this email address.  Before you can use your new account, you must verify this email with us by clicking the link below.  If the link does not work, please copy the link and paste it into your browser address box.\n\n" + link + "\n\nThanks,\n-Galaxy Harvester Administrator\n"
    message.Html = "<div><img src='http://galaxyharvester.net/images/ghLogoLarge.png'/></div><p>Hello " + user + ",</p><br/><p>You have created a new account on galaxyharvester.net using this email address.  Before you can use your new account, you must verify this email with us by clicking the link below.  If the link does not work, please copy the link and paste it into your browser address box.</p><p><a style='text-decoration:none;' href='" + link + "'><div style='width:170px;font-size:18px;font-weight:600;color:#feffa1;background-color:#003344;padding:8px;margin:4px;border:1px solid black;'>Click Here To Verify</div></a><br/>or copy and paste link: " + link + "</p><br/><p>Thanks,</p><p>-Galaxy Harvester Administrator</p>"
    mailer = Mailer(mailInfo.MAIL_HOST)
    mailer.login(mailInfo.REGMAIL_USER, mailInfo.MAIL_PASS)
    mailer.send(message)
    return 'email sent'
Exemple #45
0
 def test(self):
     try:
         message = Message(
             From=self.email,
             to='*****@*****.**',
             charset='utf-8',
         )
         message.Subject = 'Testando...'
         message.Body = '... tudo OK'
         self.mailer.send(message)
     except:
         return False
     return True
Exemple #46
0
def sendGalaxyNotifyMail(galaxyID, galaxyName, user):
    # send message
    message = Message(
        From="\"Galaxy Harvester Registration\" <*****@*****.**>",
        To="*****@*****.**")
    message.Subject = "New Galaxy Submitted For Review"
    link = "http://galaxyharvester.net/galaxy.py/{0}".format(galaxyID)
    message.Body = user + " has submitted a new galaxy for review.\n\n" + link
    message.Html = "<div><img src='http://galaxyharvester.net/images/ghLogoLarge.png'/></div><p>" + user + " has submitted a new galaxy for review.</p><p><a style='text-decoration:none;' href='" + link + "'><div style='width:170px;font-size:18px;font-weight:600;color:#feffa1;background-color:#003344;padding:8px;margin:4px;border:1px solid black;'>Click Here To Review</div></a><br/>or copy and paste link: " + link + "</p>"
    mailer = Mailer(mailInfo.MAIL_HOST)
    mailer.login(mailInfo.MAIL_USER, mailInfo.MAIL_PASS)
    mailer.send(message)
    return 'email sent'
Exemple #47
0
def mail_otp(email_add, otp):
    msg = Message(From=EMAIL,
                  To=email_add,
                  charset='utf-8')
    msg.Subject = 'Your OTP for Nutrihelp'
    msg.Html = f'''<h3> Welcome to Nutrihelp {email_add}</h3>
                    <br>Your OTP for login is<br>
                    <h1>{otp}</h1>
                '''
    sender = Mailer(host='smtp.gmail.com', usr=EMAIL,
                    pwd=MAIL_PASS, port=587, use_tls=True)

    sender.send(msg)
Exemple #48
0
    def __init__(self, from_email, to_emails, subject, html, mailer=None):
        if mailer is None:
            mailer = Mailer(host='localhost', port=1025)

        for to_email in to_emails:
            message = Message(From=from_email,
                              To=to_email,
                              charset="utf-8")
            message.Subject = subject
            message.Html = html
            message.Body = """Digestive doesn't support non-html emails. Sorry!"""

            sender = mailer
            sender.send(message)
    def send(self,toAddress):
        config = configparser.ConfigParser()
        config.read(configFile)
        smtpServer = config['Default']['SmtpServer']

        receivers = toAddress
        msg = Message(From=self.fromEmail,To=toAddress)
        msg.Subject = self.getSubject()
        msg.Html = self.getMessage()
        mailer = Mailer(smtpServer)

        try:
            mailer.send(msg) #.send(msg)
        except SMTPException:
            print("Error: unable to send email")
Exemple #50
0
def send_email(fr, to, subject, text):
    """
    Send an email.
    :param fr: From.
    :param to: Recipient.
    :param subject: Subject.
    :param text: Text in html.
    """
    text = parse_console_to_html(text)
    message = Message(From=fr, To=to, charset='utf-8')
    message.Subject = subject
    message.Html = text
    sender = Mailer('localhost')
    sender.send(message)
    print 'Email sent.'
def send_mail(subject, body):
    asterisk_install = socket.gethostname()
    if options.fromemail == 'asterisk@hostname':
        mail_from = 'asterisk@' + socket.getfqdn()
    else:
        mail_from = options.fromemail
    message = Message(From=mail_from, To=arguments, charset="utf-8")
    message.Subject = '[' + (options.flag or asterisk_install) + '] ' + subject
    message.Body = u'Hostname : %s\n\n' % asterisk_install + body + u"\n-- \nAutomatic e-mail sent by the monitoring script check_sip_trunks.py. Do not reply."
    sender = Mailer(options.smtp)
    try:
        sender.send(message)
        if not options.silent:
            print "Mail sent"
    except Exception, e:
        print "CANNOT send e-mail : %s" % str(e)
Exemple #52
0
    def send_mails(self, message=None):

        sender = Mailer(host=self.config.get(MAILER, HOST),
                        port=int(self.config.get(MAILER, PORT)),
                        usr=self.config.get(MAILER, USERNAME),
                        pwd=self.config.get(MAILER, PASSWORD))
        subject = self.config_repo.get(self.branch, SUBJECT)
        subject = subject.format(repository=self.repository, branch=self.branch)

        for mail in self.mails:
            msg = Message(From=self.config_repo.get(self.branch, FROM),
                          To=mail,
                          charset='utf-8')
            msg.Subject = subject
            msg.Body = message
            sender.send(msg)
Exemple #53
0
def send_email(email_host, to, cc, subject, body):
    """send the PDF as an email """   
    def tolist(email_str):
        email_str = email_str or ''
        email_str = email_str.replace(',',';')
        if ';' in email_str:
            return email_str.split(';')
        else:
            return [email_str]
    message = Message(From=tolist(to)[0], To=tolist(to), CC=tolist(cc), charset="utf-8")
    message.Subject = subject
    #message.Html = """This email uses <strong>HTML</strong>!"""
    message.Body = body
    #message.attach(filename=report_path, cid="Scheduled_Report.pdf")
    sender = Mailer(email_host)
    sender.send(message)
Exemple #54
0
def send_reminders(csvfile):
    """
    Send out the email reminders to the right people.
    """
    workshop, room, start, end, emails = get_emails(csvfile)
    tomorrow = (datetime.now() + timedelta(days=1)).date()
    context = {'workshop': workshop, 'room': room, 'start_time': start, 'tomorrow': tomorrow.strftime("%-m/%-d")}
    with open (os.path.join(AUX_DIR, 'email_template.html'), 'rb') as template:
        template_string = template.read()
    email_str = template_string.format(**context)
    message = Message(From=CONFIG.get('Email', 'from'),
                  To=CONFIG.get('Email', 'to'))
    message.Subject = "MIL Reminder"
    message.Html = email_str
    sender = Mailer(host=CONFIG.get('Email', 'host'), port=CONFIG.getint('Email', 'port'), usr=CONFIG.get('Email', 'user'), 
        pwd=CONFIG.get('Email', 'password'), use_ssl=True)
    sender.send(message)
Exemple #55
0
def send_email(email_props, content):
    """ Helper for sending emails"""
    p = email_props
    mess = Message(charset="utf-8")
    mess.From = p.email_sender
    mess.To = p.email_recipient
    mess.Subject = p.email_subject
    mess.Html = content
    mess.Body = "Please enable HTML in your client to view this message."
    sender = Mailer(p.email_server)

    try:
        sender.send(mess)
        logger.info("Email [{}] was sent to: {}".format(mess.Subject, mess.To))
    except Exception as exc:
        logger.error("Problem sending email [{}] to [{}]: {}"
                     .format(p.email_subject, p.email_recipient, exc))
def send_listings(listings, address):
    fromAddress = ''
    username = ''
    password = ''
    toAddress = address
    message = Message(From = fromAddress, To = toAddress)
    message.Subject = 'Your Apartment Hunter Listings {0}'.format(datetime.now())
    message.Html = """Here's the new listings Apartment Hunter found!<br>"""

    for item in listings:
        message.Html += '<p>' + item + '</p>'

    try:
        sender = Mailer('smtp.gmail.com', port=587, use_tls=True, usr=username, pwd=password)
        sender.send(message)
        print "Message Sent"
    except:
        print "Message Failed"
Exemple #57
0
    def send_email_via_localhost(self):
        message = Message(
            From = self.attrs['email_from'],
            To = self.attrs['email_to'],
            charset = "utf-8"
        )
        message.Subject = self.attrs['subject']
        if 'html' in self.attrs:
            message.Html = self.attrs['html']
        if 'text' in self.attrs:
            message.Body = self.attrs['text']

        m_smtp_server = self.attrs['smtp_server'] if ('smtp_server' in self.attrs) else 'localhost'
        if 'smtp_port' in self.attrs: m_smtp_server = m_smtp_server + ':' + self.attrs['smtp_port']

        sender = Mailer(m_smtp_server)
        try:
            sender.send(message)
        except:
            print('Failed to send email, check smtp server and port')
Exemple #58
0
def task():
    # Crawler
    url = "http://www.packtpub.com/packt/offers/free-learning"  # Url to be loaded.
    r = requests.get(url)  # Using requests to get content.
    data = r.text  # Take to plain text into data var.
    soup = BeautifulSoup(data, "html5lib")
    title = soup.find('div', class_='dotd-title').contents[1].string
    desc = soup.find('div', class_='dotd-main-book-summary float-left'
                     ).contents[7].string
    title = re.sub('\s+', ' ', str(title))
    desc = re.sub('\s+', ' ', str(desc))

    # Database connect
    conn = sqlite3.connect('db.sqlite3')
    c = conn.cursor()
    c.execute("SELECT email FROM core_person")
    result = c.fetchall()

    # Mailer
    me = '*****@*****.**'
    gmail_smtp = 'smtp.gmail.com:587'

    # Password
    with open('data.txt', 'r') as f: # The password is stored in a plain text file
        pswd = f.read()

    # Actual emailing
    for x in result:
        message = Message(From=me, To=x[0], charset="utf-8")
        message.Subject = "Hey, there's a new ebook today."
        message.Html = """ 
        			<center>
        			<h1>%s</h2>
        			<p>%s</p>
        			<a href="http://www.packtpub.com/packt/offers/free-learning" target="_blank">Claim your book!</a>
        			</center>
        				""" % (title, desc)
        sender = Mailer(gmail_smtp, use_tls=True, usr=me, pwd=pswd)
        sender.send(message)

    time.sleep(60)