ZidCopilotApp / send_email_template.py
Upto12forenglish's picture
Upload 5 files
f31a243 verified
raw
history blame contribute delete
No virus
1.94 kB
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"""
<html>
<body>
<p>Dear {username},</p>
<p>Welcome to the Naqra community!</p>
<p><span style="font-size: 20px; color: blue;">Thank you for installing the Naqra app.</span></p>
<p>Here are your login credentials:</p>
<p>Username: {username}<br>
Password: {user_password}</p>
<p><a href="{app_link}" style="text-decoration: none;">
<button style="background-color: #4CAF50; color: white; padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer;">Log in to Naqra App</button>
</a></p>
<p>If you have any questions or need assistance, please don't hesitate to reach out to our support team.</p>
<p>Best regards,<br>
Naqra Team</p>
</body>
</html>
"""
# 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()