예제 #1
0
def send_email(subject, sender, recipients, text_body, html_body):
    msg = Message(subject, sender=sender, recipients=recipients)
    msg.body = text_body
    msg.html = html_body

    # can handle other logic effectively at the same time
    Thread(target=send_async_email,
           args=(current_app._get_current_object(), msg)).start()
예제 #2
0
파일: email.py 프로젝트: boyl/mblog
def send_email(subject, sender, recipients, text_body, html_body,
               attachments=None, sync=False):
    msg = Message(subject, sender=sender, recipients=recipients)
    msg.body = text_body
    msg.html = html_body
    if attachments:
        for attachment in attachments:
            msg.attach(*attachment)
    if sync:
        mail.send(msg)
    else:
        # can handle other logic effectively at the same time
        Thread(target=send_async_email, args=(current_app._get_current_object(), msg)).start()
예제 #3
0
파일: email.py 프로젝트: todayzhou/myblog
def send_email(subject, sender, receiver, text_body, html_body, attachments=None, sync=False):
	msg = Message(subject, sender=sender, recipients=receiver)
	msg.body = text_body
	msg.html = html_body
	if attachments:
		for attachment in attachments:
			msg.attach(*attachment)
	# with open('/home/zhou/py_tools/myblog/123', 'rb') as fp:
	# 	msg.attach('123.txt', 'text/plain', fp.read())
	if sync:
		mail.send(msg)
	else:
		threading.Thread(target=send_async_mail, args=(current_app._get_current_object(), msg)).start()
예제 #4
0
def initialize_cache():
    from config import Config
    from app.api.events_cache import refresh_cache_thread, refresh_cache
    from app import scheduler, current_app

    # we'll set the run interval just little less than the CACHE TIMEOUT to avoid
    # the refresh be > CACHE_TIMEOUT
    logger.debug("initializing cache")
    refresh_cache(True)
    logger.debug("starting refresh thread")
    scheduler.add_job(refresh_cache_thread,
                      'interval',
                      seconds=Config.CACHE_TIMEOUT - 10,
                      args=[current_app._get_current_object()])
    scheduler.start()
예제 #5
0
파일: email.py 프로젝트: karomag/microblog
def send_email(subject, sender, recipients, text_body, html_body):
    """Send an email.

    Args:
        subject: subject
        sender: sender
        recipients: recipients
        text_body: text body
        html_body: html body
    """
    msg = Message(subject, sender=sender, recipients=recipients)
    msg.body = text_body
    msg.html = html_body
    Thread(
        target=send_async_email,
        args=(current_app._get_current_object(), msg),
    ).start()
def send_email(subject, sender, recipients, text_body, html_body):
    msg = Message(subject, sender=sender, recipients=recipients)
    msg.body = text_body
    msg.html = html_body
    Thread(target=send_async_email(current_app._get_current_object(),
                                   msg)).start()