Exemplo n.º 1
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)
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
0
def alert_email(feed, cfg, entry):
    """Sends alert via email.

    Args:
        feed (:py:class:`Feed`): the feed
        cfg (dict):              output config
        entry (dict):            the feed entry
    """
    logger = logging.LoggerAdapter(log, extra = {
        'feed':  feed.name,
        'group': feed.group['name'],
    })

    logger.debug(f"[{feed.name}] Alerting email: {entry.title}")

    description = strip_html(entry.description)

    try:
        smtp = Mailer(host=cfg['server'])
        message = Message(charset="utf-8", From=cfg['from'], To=cfg['to'],
                          Subject = f"{feed.group['name']} Alert: ({feed.name}) {entry.title}")
        message.Body = f"Feed: {feed.name}\nDate: {entry.datestring}\n\n{description}"
        message.header('X-Mailer', 'rssalertbot')
        smtp.send(message)

    except Exception:
        logger.exception(f"[{feed.name}] Error sending mail")
Exemplo n.º 5
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
Exemplo n.º 6
0
    def message(self, name, log_file=None, error=None, **kwargs):
        """Create an email for the given stage based upon the log file.

        If no log file is provided or it is False then the email's body will
        not include the log lines to examine, and it will not be attached. If
        an error object is given this will be used to indicate the stage
        failed.

        :stage: Name of the stage that was run.
        :log_file: Filename for the log file
        :error: Exception object that occurred.
        :returns: A Mailer message to send.
        """

        status = 'Succeeded'
        if error:
            status = 'Failed'

        kwargs = {'stage': name, 'status': status}
        subject = self.config['email']['subject'].format(**kwargs)
        to_address = kwargs.get('send_to', None) or self.config['email']['to']
        msg = Message(
            From=self.config['email']['from'],
            To=to_address,
            Subject=subject,
            Body=self.body(name, log_file, **kwargs)
        )

        compressed_log = self.compressed_log(log_file)
        if compressed_log:
            msg.attach(compressed_log)

        return msg
Exemplo n.º 7
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)
Exemplo n.º 8
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"
Exemplo n.º 9
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))
Exemplo n.º 10
0
    def message(self, name, log_file=None, error=None, **kwargs):
        """Create an email for the given stage based upon the log file.

        If no log file is provided or it is False then the email's body will
        not include the log lines to examine, and it will not be attached. If
        an error object is given this will be used to indicate the stage
        failed.

        :stage: Name of the stage that was run.
        :log_file: Filename for the log file
        :error: Exception object that occurred.
        :returns: A Mailer message to send.
        """

        status = 'Succeeded'
        if error:
            status = 'Failed'

        kwargs = {'stage': name, 'status': status}
        subject = self.config['email']['subject'].format(**kwargs)
        to_address = kwargs.get('send_to', None) or self.config['email']['to']
        msg = Message(From=self.config['email']['from'],
                      To=to_address,
                      Subject=subject,
                      Body=self.body(name, log_file, **kwargs))

        compressed_log = self.compressed_log(log_file)
        if compressed_log:
            msg.attach(compressed_log)

        return msg
Exemplo n.º 11
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)
Exemplo n.º 12
0
 def test_multiple_to(self):
     to = ['*****@*****.**', '*****@*****.**', '*****@*****.**']
     msg = Message(self.fromaddr, to, self.subject, self.bodyplain)
     txt = msg.as_string()
     result = re.search("^To: (.*)$", txt, re.M)
     self.assertTrue(result)
     self.assertEqual(result.group(1), ", ".join(to))
Exemplo n.º 13
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")
Exemplo n.º 14
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)
Exemplo n.º 15
0
    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
Exemplo n.º 16
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])
Exemplo n.º 17
0
 def test_html(self):
     msg = Message(self.fromaddr,
                   self.toaddr,
                   self.subject,
                   bodyhtml=self.bodyhtml)
     txt = msg.as_string()
     result = re.search("^Content-Type: text/html;", txt, re.M)
     self.assertTrue(result)
Exemplo n.º 18
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)
Exemplo n.º 19
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)
Exemplo n.º 20
0
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)
Exemplo n.º 21
0
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)
Exemplo n.º 22
0
 def test_many_attachments(self):
     msg = Message(self.fromaddr, self.toaddr, self.subject, self.bodyplain,
                   self.bodyhtml, self.attachments)
     txt = msg.as_string()
     pattern = re.compile("^Content-Disposition: attachment;", re.M)
     count = 0
     for match in pattern.finditer(txt):
         count += 1
     self.assertEqual(count, len(self.attachments))
Exemplo n.º 23
0
 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)
    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)
Exemplo n.º 25
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)
Exemplo n.º 26
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)
Exemplo n.º 27
0
    def send_mail(self):
    
        message =  Message(From=self.fr,
                    To=self.to,
                    Subject=self.sub,
                    Charset='utf8')
	message.Body = self.body

        sender = Mailer(host=self.server,usr=self.usr,pwd=self.pwd)
        sender.send(message)
Exemplo n.º 28
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)
Exemplo n.º 29
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)
Exemplo n.º 30
0
    def send(self):
        message = Message(From=self.render(self.sender),
                          To=self.render(self.to),
                          Subject=self.render(self.subject),
                          charset='utf-8')
        message.Body = self.render_file(self.template)
        message.Html = self.render_file(self.html_template)

        mailer = Mailer(**self.mailer_settings)
        mailer.send(message)
Exemplo n.º 31
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)
Exemplo n.º 32
0
 def send_mail(self, html):
     """
         Send a mail via smtps
     """
     message = Message(
         From=self._config['mail']['address'], To=self._config['mail']['to'],
         Subject=self._config['mail']['subject']
     )
     message.Html = html
     return self.sender.send(message)
Exemplo n.º 33
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)
Exemplo n.º 34
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)
Exemplo n.º 35
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)
Exemplo n.º 36
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)
Exemplo n.º 37
0
 def fail_mail(msg):
     if len(r.batches) >= 1:
         spec = r.batches[0].spec
     else:
         spec = "None.spec"
     log.error("%s: %s" % (spec, msg))
     m = Message()
     m.set_headers(to=r.requester_email, cc=config.builder_list)
     m.set_headers(subject="building %s failed" % spec)
     m.write_line(msg)
     m.send()
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)
Exemplo n.º 39
0
 def test_attach_pdf(self):
     att = list(filter(lambda s: s.endswith(".pdf"), self.attachments))
     msg = Message(self.fromaddr, self.toaddr, self.subject, self.bodyplain,
                   self.bodyhtml, att)
     txt = msg.as_string()
     result = re.search("^Content-Type: application/pdf", txt, re.M)
     self.assertTrue(result)
     pdf = get_attachment(txt, att[0])
     with open(att[0], 'rb') as fp:
         orig = fp.read()
     self.assertEqual(orig, pdf)
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)
Exemplo n.º 41
0
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))
Exemplo n.º 42
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)
Exemplo n.º 43
0
 def test_message_as_string(self):
     msg = Message(
         To='*****@*****.**',
         From='*****@*****.**',
         Subject='Test Message',
         Text='This is just a test message.',
         Html='<body><p>This is just a test message.</p></body>',
     )
     msg.header('Message-ID', make_msgid())
     s = msg.as_string()
     assert type(s) == str
Exemplo n.º 44
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)
Exemplo n.º 45
0
 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)
Exemplo n.º 46
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)
Exemplo n.º 47
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)
Exemplo n.º 48
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()
Exemplo n.º 49
0
    def send_report(self, message, post):
        sender = Mailer(host=settings.host, port=settings.port, usr=settings.username, 
                    pwd=settings.password, use_tls=settings.tls)
        email  = Message(From=message['reportAddress'], To=message['reportAddress'], Subject='craigslist-auto-{}'.format(datetime.datetime.now()))

        html  = 'Sent message to: <a href="{}">{}</a>\n'.format(post['url'], post['url'])
        html += 'Message Details:\nSubject: {} \nBody:\n{}'.format(message['subject'], message['body'])
        email.Html = html

        print 'Sending report for {}'.format(post['id'])

        sender.send(email)
Exemplo n.º 50
0
Arquivo: email.py Projeto: alin23/spfy
 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)
Exemplo n.º 51
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)
Exemplo n.º 52
0
    def send_reply(self, message, toAddress):
        sender = Mailer(host=settings.host, port=settings.port, usr=settings.username, 
                    pwd=settings.password, use_tls=settings.tls)
        email  = Message(From=message['fromAddress'], To=toAddress, Subject=message['subject'], CC=message['ccAddress'])
        email.Html = message['body']

        messageUploads = '{}/{}/attachments/'.format(self.uploadsBasePath, message['_id'])

        for upload in os.listdir(messageUploads):
            email.attach('{}{}'.format(messageUploads, upload))

        print 'Sending {} to {}'.format(message['subject'], toAddress)
        
        sender.send(email)
Exemplo n.º 53
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)
Exemplo n.º 54
0
 def fail_mail(msg):
     if len(r.batches) >= 1:
         spec = r.batches[0].spec
     else:
         spec = "None.spec"
     log.error("%s: %s" % (spec, msg))
     m = Message()
     m.set_headers(to = r.requester_email, cc = config.builder_list)
     m.set_headers(subject = "building %s failed" % spec)
     m.write_line(msg)
     m.send()
Exemplo n.º 55
0
    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")
Exemplo n.º 56
0
Arquivo: htmler.py Projeto: zhasm/HTML
def msg(args):
    m=Message(To=re.split(r'[\s;,]+', args.to),
              From=args.frm,
              Subject=args.subject,
              charset='utf-8'
              )
    m.Html=str(HTMLTable(args))

    sender=Mailer(host=args.host,
                  port=args.port,
                  usr=args.username,
                  pwd=args.password)
    if args.port==587:
        sender.use_tls=True
    sender.send(m)
Exemplo n.º 57
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.'
Exemplo n.º 58
0
    def notify(self):
        """ publishs the rss feed at the given url
            @param[in] fname
            @param[in] url
        """
        if not self.notifications:
            return

        message = Message(From=self.sender,
                          To=self.recipients,
                          Subject=self.subject)
        message.Body = '\n\n'.join( map(self._formatNotification, 
                                        self.notifications) )
        Mailer(self.mailhost).send(message)
        self.notifiers = []