Created
November 30, 2021 15:44
-
-
Save CrimsonScythe/1b31f4fdcdf1688d0f195adbb4184c4b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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