For the complete documentation index, see llms-docs.txt or the site index llms.txt. Full docs corpus: llms-full-docs.txt. Prefer the markdown version of this page at /docs/examples/smtp/python.md. Product capabilities: skill.md. Docs MCP: /docs/mcp. Site MCP: /mcp.

Python

Send emails via Reloop SMTP using smtplib in Python.

Python SMTP Integration

Python's built-in smtplib and email packages can be used to send emails through Reloop SMTP.

View complete runnable example on GitHub ↗

Code Example

import os
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

api_key = os.environ.get("RELOOP_API_KEY")

# Create message
msg = MIMEMultipart()
msg['From'] = 'onboarding@reloop.sh'
msg['To'] = 'delivered@resend.dev'
msg['Subject'] = 'Hello from Python smtplib'

body = '<p>Congrats on sending your first email via Reloop SMTP using smtplib!</p>'
msg.attach(MIMEText(body, 'html'))

try:
    # Connect to the server
    server = smtplib.SMTP('smtp.reloop.sh', 587)
    server.starttls()  # Upgrade connection to secure
    server.login(api_key, api_key)
    
    # Send email
    server.sendmail(msg['From'], msg['To'], msg.as_string())
    server.quit()
    print("Email sent successfully!")
except Exception as e:
    print(f"Error: {e}")

Was this page helpful?

Edit this page