コード例 #1
0
ファイル: email.py プロジェクト: saniaky/monitor-api
def send_invite_member(from_user, to_email, token, message_text):
    message = Mail(from_email=os.environ.get('FROM_EMAIL'), to_emails=to_email)
    message.template_id = 'd-d1fc8d063c1c464792606f70fe6acfbf'
    message.dynamic_template_data = {
        'inviter_name': from_user.first_name,
        'message': message_text,
        'url': 'http://localhost:3000/invitation?token=' + token
    }
    sg.send(message)
コード例 #2
0
ファイル: email.py プロジェクト: saniaky/monitor-api
def forgot_password(user):
    message = Mail(from_email=os.environ.get('FROM_EMAIL'),
                   to_emails=user.email)
    message.template_id = 'd-f626293dd98649d6b6d53a5aa3a355d4'
    message.dynamic_template_data = {
        'name': user.first_name,
        'url': base_url + '/reset-password?token=' + user.password_reset_token
    }
    sg.send(message)
コード例 #3
0
ファイル: email.py プロジェクト: saniaky/monitor-api
def welcome_email(user):
    message = Mail(from_email=from_email, to_emails=user.email)
    message.template_id = 'd-a97bb89a6bfe44fda4deba762ef6a424'
    message.dynamic_template_data = {
        'name': user.first_name,
        'url':
        base_url + '/confirm-email?token=' + user.email_verification_token
    }
    sg.send(message)
コード例 #4
0
def new_user_email_notify(user, password):
    print("sending password to ")
    print(user.email)
    message = Mail(from_email='[email protected]',
                   to_emails=user.email,
                   subject='new user',
                   html_content='<strong></strong>')
    message.dynamic_template_data = {"email": user.email, "password": password}
    message.template_id = NEW_USER_TEMPLATE_ID
    sendgrid_client = SendGridAPIClient(settings.SENDGRID_API_KEY)
    sendgrid_client.send(message)
コード例 #5
0
def send_mail_async(sender: str, receivers, subject,
                    dynamic_template_data: dict, template_id):
    message = Mail(
        from_email=sender,
        to_emails=receivers,
        subject=subject,
    )
    message.dynamic_template_data = dynamic_template_data
    message.template_id = template_id
    sg = SendGridAPIClient(settings.SENDGRID_API_KEY)
    t = threading.Thread(target=sg.send,
                         args=(message, ),
                         name=f'email to {receivers}')
    t.setDaemon(True)
    t.start()
コード例 #6
0
def pay_specialist_email_notify(payment):
    start_time = payment.enroll.timeslot.start_time
    start_time = start_time + timedelta(hours=3)
    print(start_time)
    message = Mail(from_email='[email protected]',
                   to_emails=payment.enroll.timeslot.specialist.user.email,
                   subject='new consult',
                   html_content='<strong></strong>')
    message.dynamic_template_data = {
        "date": start_time.strftime('%d/%m/%G'),
        "time": start_time.strftime('%H:%M'),
        "link": payment.enroll.timeslot.videoconf_url,
        "specialist": payment.enroll.timeslot.specialist.full_name(),
        "email": payment.enroll.user.email,
    }

    message.template_id = SPECIALIST_TEMPLATE_ID
    sendgrid_client = SendGridAPIClient(settings.SENDGRID_API_KEY)
    sendgrid_client.send(message)
コード例 #7
0
ファイル: email.py プロジェクト: saniaky/monitor-api
def password_changed(user):
    message = Mail(from_email=os.environ.get('FROM_EMAIL'),
                   to_emails=user.email)
    message.template_id = 'd-a2772ca6568e4d3ba14efede9d83c422'
    message.dynamic_template_data = {'name': user.first_name}
    sg.send(message)
コード例 #8
0
ファイル: email.py プロジェクト: saniaky/monitor-api
def email_verified(user):
    message = Mail(from_email=from_email, to_emails=user.email)
    message.template_id = 'd-334a83d006384639ad4e27d138f4de18'
    message.dynamic_template_data = {'name': user.first_name, 'url': base_url}
    sg.send(message)