Beispiel #1
0
def send_email():
    em = EmailManager()
    su = "Test mail from Hackathon"
    bd = "Hi, this is a test mail. Sent latest."
    print("Sending email...")
    em.send_email(su, '*****@*****.**', bd)
    print("done.")
    response = app.response_class(response=json.dumps('Success'),
                                  status=200,
                                  mimetype='application/json')
    return response
Beispiel #2
0
def send_email_with_link(p_fname, p_lname, p_email, course_id, course_name,
                         course_url, course_img_file):
    #course_url = "https://meet.jit.si/cs%s" %course_id
    em = EmailManager()
    text1 = "<p>Dear %s %s,</p><p></p><p>You hav been successfully enrolled into the Course: %s</p>" % (
        p_fname, p_lname, course_name)
    text = "<p></p><p>Please use the below details to join this session as per the Schedule:</p>"
    #text += "<p>&emsp;&emsp;Schedule:</p><p></p><p>&emsp;&emsp;&emsp;Date: 11/10/2017</p><p>&emsp;&emsp;&emsp;Start Time: 2:00 PM PST</p>"
    text += "<p></p><p>&emsp;&emsp;&emsp;Date: 11/10/2017</p><p>&emsp;&emsp;&emsp;Start Time: 2:00 PM PST</p>"
    text += "<p>&emsp;&emsp;&emsp;End Time:  3:00 PM PST</p><p>&emsp;&emsp;&emsp;Meeting url: %s</p>" % course_url
    text += "<p></p><p></p>See you in the classroom.<p></p><p></p>"
    text += "<p>Thanks,</p><p>Food Craft Team</p>"
    subj = "Enrollment to the course: %s" % course_name
    rcpnt = p_email
    em.send_email(subj, rcpnt, text1, text, course_img_file)
    def test_sendEmailWithAttachmentsJPG(self):

        file1 = 'images/cat.jpg'
        file2 = 'images/person.jpg'
        attachments = []
        attachments.append(file1)
        attachments.append(file2)
        eMailContent = EmailEntity('This is a test', '*****@*****.**',
                                   '*****@*****.**', 'This is the body',
                                   attachments, datetime.datetime.now())
        self.assertTrue(EmailManager().sendEmail(eMailContent, SmtpSettings()))
Beispiel #4
0
def send_email(server_username, server_pwd, smtp_server, msg_to, msg_cc,
               msg_subject, msg_content, file_name):
    mail_cfg = {
        # 邮箱登录设置,使用SMTP登录
        'server_username': server_username,
        'server_pwd': server_pwd,
        'smtp_server': smtp_server,
        # 邮件内容设置
        'msg_to': [msg_to],  # 可以在此添加收件人
        'msg_cc': msg_cc,
        'msg_subject': msg_subject,
        'msg_date': time.strftime('%Y-%m-%d %X', time.localtime()),
        'msg_content': msg_content,

        # 附件
        'attach_file': file_name
    }

    email_manager = EmailManager(**mail_cfg)

    email_manager.run()
def send_emails_with_names(credentials: Dict[str, str],
                           participants: List[Dict[str, str]]) -> None:
    email_manager: EmailManager = EmailManager()
    smtp_server_information: Dict = {"server": "smtp.gmail.com", "port": 587}
    imap_server_information: Dict[str, str] = {"server": "imap.gmail.com"}
    email_manager.open_smtp_connection(smtp_server_information, credentials)
    email_manager.open_imap_connection(imap_server_information, credentials)

    for participant in participants:
        print(
            f"Sending email to {participant['name']} at {participant['email']}..."
        )
        sending_address: str = credentials["username"]
        to: str = participant["email"]
        body: str = f"Hi {participant['name']},\nYou drew {participant['drawn_name']}\n\nThis is an automated message, do not respond."
        subject: str = "Name Drawing"
        email_manager.send_email(sending_address, to, subject, body)

    email_manager.delete_all_emails("Trash")
    email_manager.close_smtp_connection()
    email_manager.close_imap_connection()
def main():
    logging.info('************* BEGIN check_false_alarms.py ************')
    mailManager = EmailManager()
    #Count number of emails

    numMails = mailManager.checkMailbox(MailboxSettings())
    logging.info('Found %s emails', str(numMails))
    if (numMails > 0):
        yolo = YoloClassifier()
    #For every email
    if (numMails > 5):
        numMails = 5
        logging.info('Only 5 emails will be checked in this execution.')
    for i in range(numMails):
        #Get the pictures
        logging.info('**** Checking email with ID %i ****', i)
        eMailInfo = mailManager.getInfoFromEmail(i, MailboxSettings())
        images = eMailInfo.getAttachments()
        if (len(images) == 0):
            logging.info('No images found in the email with ID %i', i + 1)
        else:
            #For every image, call Yolo try to detect a person
            for oneImage in images:
                logging.info('Checking image %s', oneImage)
                if (yolo.findPersonInPictureWithCandidates(
                        ImageFile(oneImage)) == True):
                    logging.info('Found person in picture %s', oneImage)
                    #Send email to notify there is a real alert
                    #Prepare the contents of the alert
                    eMailContentAlert = mailManager.prepareAlert(eMailInfo)
                    #Send the email
                    mailManager.sendEmail(eMailContentAlert, SmtpSettings())
                    break
                else:
                    logging.info('No person found in picture %s', oneImage)
    #Remove the emails once they have been processed
    #mailManager.multipleDeleteEmail(range(numMails),MailboxSettings())
    logging.info('************* END check_false_alarms.py ************')
Beispiel #7
0
from datetime import datetime, timedelta
from data_manager import DataManager
from flight_search import FlightSearch
from notification_manager import NotificationManager
from view import View
from email_manager import EmailManager

data_manager = DataManager()
sheet_data = data_manager.get_destination_data()
flight_search = FlightSearch()
notification_manager = NotificationManager()
ui = View()
email = EmailManager()
user_data = data_manager.get_users()

if user_data[0] != "":
    for row in user_data:
        email.send_email(row["email"])

ORIGIN_CITY_IATA = "LON"

if sheet_data[0]["iataCode"] == "":
    for row in sheet_data:
        row["iataCode"] = flight_search.get_destination_code(row["city"])
    data_manager.destination_data = sheet_data
    data_manager.update_destination_codes()

tomorrow = datetime.now() + timedelta(days=1)
six_month_from_today = datetime.now() + timedelta(days=(6 * 30))

for destination in sheet_data:
Beispiel #8
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2018/12/17 14:03
# @Author  : Bilon
# @File    : run.py
import unittest
from HTMLTestRunner import HTMLTestRunner
from ccloud.common.myunit import create_report_file
from email_manager import EmailManager

# 微信用例目录
dir_path = '../test_case'

# 加载测试用例,目录下以 "test" 开头的 ".py"文件
discover = unittest.defaultTestLoader.discover(dir_path, pattern='test*.py')

# 报告输出路径
file = create_report_file()

# 运行用例并生成测试报告
with open(file, 'wb') as f:
    runner = HTMLTestRunner(stream=f, title=u'APP测试报告', description=u'测试结果:')
    runner.run(discover)

# 自动发送邮件
manager = EmailManager()
manager.send()
def index():
    em = EmailManager()
    su = "Test mail from Hackathon"
    bd = "Hi, this is a test mail."
    em.send_email(su, '*****@*****.**', bd)
    return "sent"
 def test_checkMailbox(self, ):
     self.assertTrue(type(EmailManager().checkMailbox(MailboxSettings())),
                     int)
 def test_getInfoFromEmail(self):
     res = EmailManager().getInfoFromEmail(0, MailboxSettings())
     print(res.toJSONObject())
     self.assertTrue(len(res.getFrom()) > 0)
 def test_sendEmailWithException(self):
     eMailContent = EmailEntity('This is a test', '*****@*****.**',
                                '*****@*****.**', 'This is the body',
                                [], datetime.datetime.now())
     self.assertFalse(EmailManager().sendEmail(eMailContent,
                                               SmtpSettings()))
Beispiel #13
0
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# ======================================================================================================================
# The MIT License (MIT)
# ======================================================================================================================
# Copyright (c) 2016 [Marco Aurélio Prado - [email protected]]
# ======================================================================================================================
from flask import Blueprint

from email_manager import EmailManager


email_blueprint = Blueprint("email", __name__, static_folder="static", template_folder="templates")
email_manager = EmailManager()
Beispiel #14
0
from amazon_scrapper import AmazonScrapper
product_url = None

amazon_scrapper = AmazonScrapper()
data = amazon_scrapper.get_product_price()

if data:
    from email_manager import EmailManager
    email_manager = EmailManager(data)
    email_manager.send_message()