micromail/examples/minimal.py

25 lines
612 B
Python

from micromail import MicromailClient
# Create an SMTP client
client = MicromailClient(
host="mail.example.com",
port=465,
ssl=True,
)
# Connect to the server
client.connect()
# Login to the server
client.login("example@example.com", "password")
# Initialize a new message
client.new_message("example@example.org")
# Set message headers
# WARNING: This will send a message with a very wrong date if time is not correct on the device
# --- It might be rejected by the mail server
client.headers()
# Write message content
client.write_line("Hello world!")
# Send message
client.send()
client.quit()