46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
import logging
|
|
|
|
from background_task import background
|
|
from background_task.tasks import TaskSchedule
|
|
from django.core.mail import send_mail
|
|
|
|
from bid_main.models import User
|
|
import bid_main.email
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
@background(schedule={'action': TaskSchedule.RESCHEDULE_EXISTING})
|
|
def send_new_user_session_email(user_pk, session_data):
|
|
user = User.objects.get(pk=user_pk)
|
|
log.info("sending a new user session email for account %s", user.pk)
|
|
|
|
# sending only a text/plain email to reduce the room for look-alike phishing emails
|
|
email_body_txt, subject = bid_main.email.construct_new_user_session(user, session_data)
|
|
|
|
email = user.email
|
|
send_mail(
|
|
subject=subject,
|
|
message=email_body_txt,
|
|
from_email=None, # just use the configured default From-address.
|
|
recipient_list=[email],
|
|
)
|
|
|
|
|
|
@background(schedule={'action': TaskSchedule.RESCHEDULE_EXISTING})
|
|
def send_password_changed_email(user_pk):
|
|
user = User.objects.get(pk=user_pk)
|
|
log.info("sending a password change email for account %s", user.pk)
|
|
|
|
# sending only a text/plain email to reduce the room for look-alike phishing emails
|
|
email_body_txt, subject = bid_main.email.construct_password_changed(user)
|
|
|
|
email = user.email
|
|
send_mail(
|
|
subject=subject,
|
|
message=email_body_txt,
|
|
from_email=None, # just use the configured default From-address.
|
|
recipient_list=[email],
|
|
)
|