Django
1
Вклад в тег
mango_json = {
"command_id": "sms",
"text": sms_text,
"from_extension": "111",
"to_number": phone_number,
"sms_sender": "name"
}
# генерируем подпись
sign = sha256(settings.MANGO_API_KEY + json.dumps(mango_json) + settings.MANGO_SALT).hexdigest()
data = {
'vpbx_api_key': settings.MANGO_API_KEY,
'sign': sign,
'json': json.dumps(mango_json)
}
requests.post(self.sms_api_url, data=data)
EMAIL_HOST_YA = 'smtp.yandex.ru'
EMAIL_PORT_YA = 587
EMAIL_HOST_USER_YA = 'new.mail@yandex.ru'
EMAIL_HOST_PASSWORD_YA = '1234'
from django.core.mail import get_connection, send_mail
#connections to yandex
connection = get_connection(
host=settings.EMAIL_HOST_YA,
port=settings.EMAIL_PORT_YA,
username=settings.EMAIL_HOST_USER_YA,
password=settings.EMAIL_HOST_PASSWORD_YA,
use_tls=True
)
send_mail(
subject,
text_content,
from_email,
to,
connection=connection,
html_message=html_content
)