You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

19 lines
645 B

from twilio.rest import Client
from django.core.mail import EmailMessage
from django.conf import settings
from django.template.loader import get_template
from project.celery import app
@app.task
def send_email(subject, to_email, template_name, attachments=[], **kwargs):
html = get_template(template_name).render(kwargs)
email = EmailMessage(subject, html, to=[to_email], attachments=attachments)
email.content_subtype = 'html'
email.send()
def send_sms(message, phone):
client = Client(settings.TWILIO_ACCOUNT, settings.TWILIO_TOKEN)
client.messages.create(to=phone, from_=settings.TWILIO_FROM_PHONE, body=message)