Skip to content

Instantly share code, notes, and snippets.

@CrimsonScythe
Created November 30, 2021 15:44
Show Gist options
  • Save CrimsonScythe/1b31f4fdcdf1688d0f195adbb4184c4b to your computer and use it in GitHub Desktop.
Save CrimsonScythe/1b31f4fdcdf1688d0f195adbb4184c4b to your computer and use it in GitHub Desktop.
import yagmail
from celery import Celery
from default_settings import *
import time
celery = Celery(
'mailasync',
broker='pyamqp://guest@localhost//'
)
mail = yagmail.SMTP(MAIL_USERNAME, MAIL_PASSWORD)
@celery.task()
def sendMail(data):
''' simulate long-running task'''
time.sleep(5.0)
''' send email '''
receiver=data['to']
contents = ["Celery is awesome!"]
mail.send(receiver, 'Sent from a worker', contents)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment