LIL-74 Added `twilio`

remotes/origin/hasaccess
Sergey G 8 years ago
parent af5492c797
commit ff306d2378
  1. 8
      apps/notification/utils.py
  2. 8
      project/settings.py
  3. 3
      requirements.txt

@ -1,4 +1,7 @@
from twilio.rest import Client
from django.core.mail import EmailMessage
from django.conf import settings
from django.template.loader import get_template
@ -7,3 +10,8 @@ def send_email(subject, to_email, template_name, **kwargs):
email = EmailMessage(subject, html, to=[to_email])
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)

@ -136,3 +136,11 @@ ANYMAIL = {
}
EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend"
DEFAULT_FROM_EMAIL = "postmaster@mail.9ev.ru"
# SMS
# https://github.com/twilio/twilio-python
TWILIO_ACCOUNT = ''
TWILIO_TOKEN = ''
TWILIO_FROM_PHONE = ''

@ -1,3 +1,4 @@
Django==2.0.1
django-anymail[mailgun]==1.2
paymentwall-python==1.0.7
paymentwall-python==1.0.7
twilio==6.10.0
Loading…
Cancel
Save