diff --git a/project/myauth/emails.py b/project/myauth/emails.py index 5028834..3073c56 100644 --- a/project/myauth/emails.py +++ b/project/myauth/emails.py @@ -2,6 +2,7 @@ from django.template.loader import render_to_string from django.core.mail import EmailMessage from django.conf import settings + from celery.decorators import task @@ -19,6 +20,17 @@ def send_registration_email(user_email, confirm_url): return email.send() +@task +def send_welcome_email(user_email): + """Отправить приветственное письмо.""" + template_name = 'myauth/welcome_email.txt' + subject = u'Добро пожаловать на Документор!' + dict_context = {'support_email': SUPPORT_EMAIL,} + email_body = render_to_string(template_name, dict_context) + email = EmailMessage(subject=subject, to=(user_email,), body=email_body) + return email.send() + + @task def send_reset_password_email(user_email, confirm_url): """Отправить письмо с ключём для восстановления пароля.""" diff --git a/project/myauth/views.py b/project/myauth/views.py index 4bcd007..be50c3b 100644 --- a/project/myauth/views.py +++ b/project/myauth/views.py @@ -97,6 +97,7 @@ def confirm_registered_email(request, key): any_licenses = License.objects.filter(company=user.profile).exists() if not any_licenses: license = License.objects.create_test_period_license(company=user.profile) + emails.send_welcome_email.delay(new_user.email, confirm_url) user.profile.confirmed = True user.profile.active = True user.profile.save() diff --git a/project/templates/myauth/welcome_email.txt b/project/templates/myauth/welcome_email.txt new file mode 100644 index 0000000..279b822 --- /dev/null +++ b/project/templates/myauth/welcome_email.txt @@ -0,0 +1,7 @@ +Здравствуйте! + +Приветствуем вас на Документоре. + +Это письмо написано роботом. Отвечать на него не нужно. + +Связаться со службой поддержки сайта Документор Вы можете по адресу {{ support_email }}