示例#1
0
def job():
    from gmail import GMail, Message
    import random

    gmail = GMail('*****@*****.**','techkids')

    symptom_dictionary = {
        'đau bụng':'dạ dày',
        'đau chân':'xương khớp',
        'mệt mỏi':'ung thư',
    }

    html_template = '''
    <p>Ch&agrave;o sếp</p>
    <p><strong>S&aacute;ng nay</strong> em {{ symptom }} qu&aacute;. Chắc l&agrave; em bị {{ disease }} rồi&nbsp;</p>
    <p><span style="color: #993366;">Cho em xin nghỉ ahuhu</span></p>
    <p>&nbsp;</p>
    '''

    #get random symptom and disease
    symp_disease = []
    symp_disease = random.choice(list(symptom_dictionary.items()))
    html_content = html_template.replace("{{ symptom }}",symp_disease[0])
    html_content = html_content.replace("{{ disease }}",symp_disease[1])

    msg = Message('This is Yen',to='*****@*****.**',html=html_content,attachments=[])

    gmail.send(msg)
    return schedule.cancel_job
示例#2
0
def cli():
    import argparse, getpass, mimetypes, sys

    parser = argparse.ArgumentParser(
        description='Send email message via GMail account')
    parser.add_argument('--username',
                        '-u',
                        required=True,
                        help='GMail Username')
    parser.add_argument('--password',
                        '-p',
                        default=None,
                        help='GMail Password')
    parser.add_argument('--to',
                        '-t',
                        required=True,
                        action='append',
                        default=[],
                        help='To (multiple allowed)')
    parser.add_argument('--cc',
                        '-c',
                        action='append',
                        default=[],
                        help='Cc (multiple allowed)')
    parser.add_argument('--subject', '-s', required=True, help='Subject')
    parser.add_argument('--body', '-b', help='Message Body (text)')
    parser.add_argument('--html',
                        '-l',
                        default=None,
                        help='Message Body (html)')
    parser.add_argument('--attachment',
                        '-a',
                        action='append',
                        default=[],
                        help='Attachment (multiple allowed)')
    parser.add_argument('--debug',
                        '-d',
                        action='store_true',
                        default=False,
                        help='Debug')

    results = parser.parse_args()

    if results.password is None:
        results.password = getpass.getpass("Password:"******",".join(results.to),
                  cc=",".join(results.cc),
                  text=results.body,
                  html=results.html,
                  attachments=results.attachment)
    gmail.send(msg)
    gmail.close()
def sent_mail(x):
    gmail = GMail("*****@*****.**", "Theeternal0610")
    html_content = """Yêu cầu của bạn đã được xử lý, 
    chúng tôi sẽ liên hệ với bạn trong thời gian sớm nhất. 
    Cảm ơn bạn đã sử dụng dịch vụ của 'Mùa Đông Không Lạnh'"""
    msg = Message('Mùa Đông Không Lạnh', to=x, html=html_content)
    gmail.send(msg)
示例#4
0
async def main():
    logger = get_logger()
    logger.info("Start")
    auth = GAuth(logger)
    with open(f'{os.environ.get("SECRETS")}/creds.json', 'r') as f:
        creds = json.load(f)

    mail = GMail(auth.mail, logger)
    session = aiohttp.ClientSession()
    reports = Reports(session, mail, creds, logger)
    # Login
    login = asyncio.create_task(reports.login())

    # Get events to process
    calendar = GCal(auth.calendar, creds["cal_id"], logger)
    calendar.query_calendar()

    # Make sure we're logged in & process events
    await login
    if len(calendar.users) > 0:
        # Call reports.dowload_reports_and_send_draft for each new event, this downloads report and creates draft
        done, pending = await asyncio.wait([
            reports.download_reports_and_send_draft(data)
            for data in calendar.users
        ])

        # Patch events that drafts were succesfully created for (returned +ve)
        for task in done:
            if result := task.result():
                calendar.patch(result)
示例#5
0
def send():
    gmail = GMail('*****@*****.**', 'tuananh1k95')
    msg = Message('message', to='*****@*****.**', text="Hello world")

    gmail.send(msg)

    return "Sended"
示例#6
0
def job():

    mail = GMail('*****@*****.**', 'Sgs123456')
    #mail = GMail('A.User <*****@*****.**>','password')

    html_content = """
    <p style="text-align: center;">Cộng h&ograve;a x&atilde; hội chủ nghĩa Việt Nam</p>
    <p style="text-align: center;">Độc lập - Tự do - Hạnh ph&uacute;c</p>
    <p style="text-align: center;"><strong>ĐƠN XIN NGHỈ HỌC</strong></p>
    <p style="text-align: left;">K&iacute;nh gửi: Thầy</p>
    <p style="text-align: left;">T&ecirc;n em l&agrave; Minh.</p>
    <p style="text-align: left;">H&ocirc;m nay em xin nghỉ học vì {{ốm}}.</p>
    <p style="text-align: left;">Minh</p>
    """

    sickness = ["đau bụng", "ẩy chỉa", "sốt xuất huyết"]

    reason = random.choice(sickness)

    html_content = html_content.replace("{{ốm}}", reason)

    message = Message("Test",
                      "*****@*****.**",
                      html=html_content)

    mail.send(message)
示例#7
0
def contact(db):
    """
    Our contact-us form, basically, present a form if it's a GET request,
    validate and process the form if it's a POST request. Filthy but works.
    """
    form = ContactForm(request.POST, nocaptcha={'ip_address': '127.0.0.1'})
    if request.method == 'POST' and form.validate():
        # process the form, captcha is valid.

        message_text = "Contact Email: {email}\n\n {contact_text}".format(
            email=form.email.data, contact_text=form.contact_text.data)

        # put together a gmail client for sending messages
        gmail_client = GMail(settings.ADMIN_EMAIL,
                             settings.ADMIN_EMAIL_PASSWORD)
        message = Message('[xqzes] Contact Form',
                          to=settings.ADMIN_EMAIL,
                          text=message_text)
        gmail_client.send(message)

        return redirect("/contact/?contacted=True")

    return template('contact',
                    form=form,
                    contacted=strtobool(request.GET.get('contacted', 'false')))
示例#8
0
def send_ebook(book, convert=False):
    print('sending %r' % book)
    gm = GMail(*settings.GMAIL_AUTH)
    m = Message("convert" if convert else "regular",
                to=settings.KINDLE_EMAIL,
                text="foo",
                attachments=[book])
    gm.send(m)
示例#9
0
文件: iot.py 项目: ybaransky/hunterpi
def init_gmail(parser):
    email = parser.get("gmail", "email")
    password = parser.get("gmail", "password")
    enabled = parser.getboolean("gmail", "enabled")
    subject = os.uname()[1]
    gm = GMail(email, password, subject, enabled)
    logging.info("gmail %s" % gm)
    return gm
示例#10
0
def sent_mail_verify(x, y):
    gmail = GMail("*****@*****.**", "Theeternal0610")
    html_content = """
    Cảm ơn bản đã sử dụng dịch vụ của chúng tôi
    Vui lòng click vào link dưới để xác nhận đăng ký tài khoản:{}
    Trân trọng cảm ơn!""".format(y)
    msg = Message('Xác nhận đăng ký tài khoản', to=x, html=html_content)
    gmail.send(msg)
示例#11
0
def sent_mail(x, y):
    gmail = GMail("*****@*****.**", "Theeternal0610")
    html_content = """
    Cảm ơn bản đã sử dụng dịch vụ của chúng tôi
    Mật khẩu mới của bạn là:{}
    Trân trọng cảm ơn!""".format(y)
    msg = Message('Khôi phục mật khẩu', to=x, html=html_content)
    gmail.send(msg)
示例#12
0
def get_mailer():
    with open('config.txt', 'r') as configfile:
        lines = [x for x in configfile]
        username = lines[0].rstrip().replace(' ', '')
        password = lines[1].rstrip().replace(' ', '')
    print 'connecting with ' + username + ' ' + password
    gmailer = GMail(username, password)
    gmailer.connect()
    return gmailer
示例#13
0
def accept(order_id):
    order = Order.objects().with_id(order_id)
    order.update(set__is_accepted=True)
    order.reload()
    gmail = GMail('*****@*****.**', 'vukhanhduy')
    mess = "Yêu cầu của bạn đã được xử lý, chúng tôi sẽ liên hệ với bạn trong thời gian sớm nhất. Cảm ơn bạn đã sử dụng dịch vụ của ‘Mùa Đông Không Lạnh"
    msg = Message('Hello', to=order.email, html=mess)
    gmail.send(msg)
    return redirect(url_for('ordermanagement'))
示例#14
0
文件: app.py 项目: hoad211/WebDemo
def send_email():
    # customer_id = Customer.objects().with_id(service_id)
    # packages = session['packages']
    content = open('templates/mail.html', encoding="utf8").read()
    gmail = GMail('*****@*****.**', '123@123a')
    # msg = Message('Test Message',to = Customer[5], html = content)
    msg = Message("Test message", to=Customer[5], html=content)
    gmail.send(msg)
    return 'thank you'
示例#15
0
 def send(self):
     print('Sending {}'.format(self.title))
     gmail = GMail(GMAIL_ACCOUNT, GMAIL_PASSWD)
     msg = Message(self.title,
                   to=MAIL_TO,
                   text=self.text,
                   attachments=self.attachments)
     gmail.send(msg)
     gmail.close()
     print('Ok. Sent Edison: {}'.format(self.title))
示例#16
0
def accept(id, id2):
    Order.objects.with_id(id).update(set__is_accepted=True)
    user = User.objects.with_id(id2)
    html_content = """
    <p style="text-align: center;">“Yêu cầu của bạn đã được xử lý, chúng tôi sẽ liên hệ với bạn trong thời gian sớm nhất. Cảm ơn bạn đã sử dụng dịch vụ của ‘Mùa Đông Không Lạnh’”</p>
    """
    gmail = GMail('*****@*****.**', 'english1996')
    msg = Message('TEST', to=user.email, html=html_content)
    gmail.send(msg)
    return "SUCCESSFULLY REQUEST"
def main(verbose, test, debug, gmail_token, bind_addr, port):
    global gmail

    logging.info(f'Started {APP_NAME}')

    # the custom json encoder for the AppData Object
    app.json_encoder = CustomJSONEncoder

    # quiet the output from some of the libs
    logging.getLogger('werkzeug').setLevel(logging.ERROR)
    logging.getLogger('requests').setLevel(logging.ERROR)
    logging.getLogger('urllib3').setLevel(logging.ERROR)
    logging.getLogger('apscheduler').setLevel(logging.WARNING)

    # get environment variable for gmail server
    if gmail_token:
        logging.info(f'Gmail server enabled.')
        if debug:
            gmail = GMail(f'{APP_NAME} <*****@*****.**>',
                          gmail_token)
        else:
            gmail = GMailWorker(f'{APP_NAME} <*****@*****.**>',
                                gmail_token)
    else:
        logging.warning('Gmail server token not defined.')

    # bind locally to a free port
    logging.info(f'Bind Address: {bind_addr}:{port}')

    # more verbose logging when this is set and use flask webserver
    logging.info(f'Debug set to {debug}')

    # start the scheduler out... nothing to do right now
    sched.start()

    # register this service with zeroConf
    zc = registerService(bind_addr, port)

    logging.info('running restapi server press Ctrl+C to exit.')
    try:
        logging.getLogger('waitress').setLevel(logging.ERROR)
        if debug:
            # run the built-in flask server
            # FOR DEVELOPMENT/DEBUGGING ONLY
            app.run(host=bind_addr, port=port, debug=False)
        else:
            # Run the production server
            waitress.serve(app, host=bind_addr, port=port)
    except (KeyboardInterrupt, SystemExit):
        logging.info('Shutting down scheduler task.')
        sched.shutdown()
        zc.unregister_service(logging.info)
        zc.close()
    except (RuntimeError):
        logging.error('RuntimeError.')
def send_email(recipient=matt_email, msg='test'):
    try:
        gmail = GMail(maddie_email, app_password)
        msg1 = Message(f"Maddie's Math Results from {time}",
                       to=recipient,
                       text=msg)

        gmail.send(msg1)
        print("Message sent!")
    except Exception as e:
        print(f"Error sending email results. Error message: \n {e}")
示例#19
0
 def start(self):
     instance = OnlineStorage.OnlineStorage
     if self.args.service == "google_drive":
         instance = GoogleDrive.GoogleDrive(self)
         instance.sync()
     if self.args.service == "dropbox":
         instance = Dropbox.Dropbox(self)
         instance.sync()
     if self.args.service == "gmail":
         instance = GMail.GMail(self)
         instance.sync()
def send_email():
    bitcoin_price = get_bitcoin_price()

    # enter actual password, otherwise, nothing happens.
    gmail = GMail(f"{SENDER_TITLE} <{USERNAME}>",
                  password=f'{PASSWORD}')
    message = Message(f'Bitcoin is at {bitcoin_price} right now!',
                      to=RECIPIENT,
                      text=f'The current Bitcoin price is {bitcoin_price}.')

    gmail.send(message)
示例#21
0
def send_email():

    report = generate_report()
    print(report)

    gmail = GMail('Storj Notification <{}>'.format(EMAIL_USERNAME),
                  password=EMAIL_PASSWORD)
    message = Message("Daily Storj Report For Node {}".format(NODE_NICKNAME),
                      to=EMAIL_SENDTO,
                      text=report)

    gmail.send(message)
示例#22
0
    def get_handler(email_address: str, api_key: str) -> GMail:
        """
        Returns an EmailApp handler.

        :param email_address:
        :param api_key:
        :return:
        """

        gmail_handler = GMail(username=email_address, password=api_key)
        gmail_handler.connect()
        return gmail_handler
示例#23
0
 def test_gmail(self):
     gmail = GMail(os.environ['GMAIL_ACCOUNT'],
                   os.environ['GMAIL_PASSWD'])
     msg1 = Message('GMail Test Message #1',
                    to=os.environ['GMAIL_RCPT'],
                    text='Hello')
     msg2 = Message('GMail Test Message #2',
                    to=os.environ['GMAIL_RCPT'],
                    text='Hello')
     gmail.send(msg1)
     gmail.send(msg2)
     gmail.close()
示例#24
0
def order(order_id):
    all_order = Order.objects.with_id(order_id)
    service_id = all_order.service.id
    all_services = Service.objects.with_id(service_id)
    all_order.update(set__is_accepted=True)
    all_services.update(set__status=False)
    user_mail = all_order['user']['email']
    html_content = ''' Yêu cầu của bạn đã được xử lý, chúng tôi sẽ liên hệ với bạn trong thời gian sớm nhất. Cảm ơn bạn đã sử dụng dịch vụ của "Mùa Đông Không Lạnh" '''
    gmail = GMail('*****@*****.**', '01662518199')
    msg = Message('Mùa Đông Không Lạnh', to=user_mail, html=html_content)
    gmail.send(msg)
    return redirect(url_for('show_order'))
示例#25
0
def email(email):
    gmail = GMail('Nhung nhúc <*****@*****.**>', 'phong1910')

    html_content = """<p>Yêu cầu của bạn đã được xử lý, chúng tôi sẽ liên hệ với bạn trong thời gian sớm nhất. Cảm ơn bạn đã sử dụng dịch vụ của ‘Mùa Đông Không Lạnh’ </p>"""

    msg = Message('Confirmation email',
                  to='User <email>',
                  html=html_content,
                  email=email)
    gmail.send(msg)
    print("Gửi thành công")

    gmail.send(msg)
示例#26
0
    def send(self, person, information):
        gmail = GMail(env("GMAIL_USERNAME"), env("GMAIL_PASSWORD"))

        subject = "Fresh {info} {ip} !".format(info=information,
                                               ip=person["ip"])

        to = env("EMAIL")

        body = self.prepareBody(person)

        message = Message(subject=subject, to=to, html=body)

        gmail.send(message)
def accept(order_id):
    if "loggedin" in session:
        order = Order.objects.with_id(order_id)
        order.update(set__is_accepted=True)
        user = User.objects(account=order.service_user)
        for i in user:
            mail = i.email
        gmail = GMail('*****@*****.**', 'chung20150413')
        msg = Message('Test Message', to=mail, text='Hello')
        gmail.send(msg)
        all_order = Order.objects()
        return render_template('order.html', all_order=all_order)
    else:
        return redirect(url_for("login"))
def sign_up():
    confirm_username = False
    confirm_email = False
    if request.method == "GET":
        return render_template("sign_up.html")
    elif request.method == "POST":
        form = request.form
        users = User.objects()
        for user in users:
            if form["email"] == user["email"]:
                confirm_email = True
            if form['username'] == user['username']:
                confirm_username = True
        if confirm_email:
            return "Email has been used. Try again"
        elif confirm_username:
            return "Username has been used. Try again"
        else:
            str_password = str(randint(1000, 9999))

            new_user = User(fullname=form["fullname"],
                            email=form["email"],
                            username=form["username"],
                            password=str_password)
            new_user.save()
            users = User.objects(username=form["username"])
            from gmail import GMail, Message
            accept_account = """
            <h1>Accept your Warm winter Account</h1>
<h3><strong>Username: {{username}}</strong></h3>
<h3>Password: {{password}}</h3>
<p>" You can change your password in here :<a href="http://*****:*****@gmail.com', 'duchoa119')
            msg = Message('Accept Account',
                          to=form['email'],
                          html=accept_account)
            gmail.send(msg)
            return "Check your Email to Loggin"
示例#29
0
文件: app.py 项目: culee/c4e
def edit_order(order):
    f_order = Order.objects.with_id(order)
    f_order.update(set__is_accepted=True)

    gmail = GMail("*****@*****.**", "minimalism")
    html_content = """
    <p> Yêu cầu của bạn đã được xử lý, chúng tôi sẽ liên hệ với bạn trong thời gian sớm nhất. Cảm ơn bạn đã sử dụng dịch vụ của ‘Mùa Đông Không Lạnh’</p>
    """
    msg = Message('Xac nhan yeu cau',
                  to=f_order.user_id.email,
                  html=html_content)
    gmail.send(msg)

    return redirect(url_for('order_list'))
示例#30
0
def verify_email(reveive_email, name, code):
    mail = GMail("smartexam.c4e22", "Sm@rt123456")
    body = '''
    <div>
    <div>Dear {0},</div>
    <div>You have just signed up for Smart-Exam. Well done!</div>
    <div>Would you mind just validating that this is really your email address?</div>
    <div>Here is the verify code: {1}</div>
    <div>For additional help, please feel free to contact us via [email protected].</div>
    </div>
    '''.format(name, code)

    msg = Message("Smart-Exam confirmation email", to=reveive_email, html=body)
    mail.send(msg)