-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
30 lines (23 loc) · 806 Bytes
/
Copy pathmain.py
File metadata and controls
30 lines (23 loc) · 806 Bytes
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
import os
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from dotenv import load_dotenv
load_dotenv()
api_key = os.environ.get("RELOOP_API_KEY")
if not api_key:
print("Error: RELOOP_API_KEY environment variable is required.")
exit(1)
msg = MIMEMultipart()
msg["From"] = "onboarding@yourdomain.com"
msg["To"] = "recipient@example.com"
msg["Subject"] = "Hello from Reloop SMTP"
body = "<p>Congrats on sending your first email via Reloop SMTP!</p>"
msg.attach(MIMEText(body, "html"))
try:
with smtplib.SMTP_SSL("smtp.reloop.sh", 465) as server:
server.login("reloop", api_key)
server.sendmail(msg["From"], [msg["To"]], msg.as_string())
print("Email sent successfully!")
except Exception as e:
print(f"Error: {e}")