Advertisement
KNenov96

Untitled

Mar 31st, 2023
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. import boto3
  2.  
  3.  
  4. class EmailService:
  5.     def __init__(self, access_key, secret_key, region_name='eu-north-1'):
  6.         self.ses = boto3.client(
  7.             'ses',
  8.             region_name=region_name,
  9.             aws_access_key_id=access_key,
  10.             aws_secret_access_key=secret_key
  11.         )
  12.         self.sender = 'k.nenov96@abv.bg'
  13.  
  14.     def send_registration_confirmation_email(self, recipient_email, email_token):
  15.         subject = 'Registration Successful'
  16.         message = f'Thank you for registering! ' \
  17.                   f'Link for verifying email: http://127.0.0.1:5000/verify_email/{email_token}'
  18.  
  19.         response = self.ses.send_email(
  20.             Source=self.sender,
  21.             Destination={
  22.                 'ToAddresses': [recipient_email]
  23.             },
  24.             Message={
  25.                 'Subject': {'Data': subject},
  26.                 'Body': {'Text': {'Data': message}}
  27.             }
  28.         )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement