import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText def send_email(receiver_email, username, user_password, app_link): # Email account credentials sender_email = "naqra.app@outlook.com" sender_password = "@naserCSE92" # Replace with the actual password # Email content subject = "Thank You for Installing Naqra App" body = f"""

Dear {username},

Welcome to the Naqra community!

Thank you for installing the Naqra app.

Here are your login credentials:

Username: {username}
Password: {user_password}

If you have any questions or need assistance, please don't hesitate to reach out to our support team.

Best regards,
Naqra Team

""" # Create the email message msg = MIMEMultipart() msg['From'] = sender_email msg['To'] = receiver_email msg['Subject'] = subject # Attach the email body with HTML content msg.attach(MIMEText(body, 'html')) try: # Connect to the Outlook SMTP server server = smtplib.SMTP('smtp.office365.com', 587) server.starttls() # Log in to the email account server.login(sender_email, sender_password) # Send the email server.send_message(msg) print("Email sent successfully!") except Exception as e: print(f"Failed to send email. Error: {e}") finally: # Terminate the SMTP session server.quit()