File size: 1,394 Bytes
f1495be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import smtplib

# Function to send activation email with HTML content
def send_activation_email(email: str, activation_otp: int):
    sender_email = "chandratresoham@gmail.com"  # Update with your email address
    sender_password = "wbuc okcv hzzn iwyx"  # Update with your email password
  # Update with your website URL
    
    # HTML content for the email body
    email_body = f"""
    <html>
        <body>
            <p>
                Hello,<br><br>
                You have successfully registered to the system.<br><br>
                Please enter below otp to verify your accout<br><br>
                <p style="font-size:17px; font-weight:bold">{activation_otp}</p><br><br>
                Thank you!<br>
            </p>
        </body>
    </html>
    """

    # Create MIMEText object with HTML content
    message = MIMEMultipart("alternative")
    message['From'] = sender_email
    message['To'] = email
    message['Subject'] = "Activate your account"
    message.attach(MIMEText(email_body, 'html'))

    # Connect to SMTP server and send email
    with smtplib.SMTP('smtp.gmail.com', 587) as server:  # Update with your SMTP server details
        server.starttls()
        server.login(sender_email, sender_password)
        server.sendmail(sender_email, email, message.as_string())