Add minimal example script and update README with warning about date synchronization

This commit is contained in:
Edgar P. Burkhart 2025-05-17 21:06:55 +02:00
parent 9d5419566c
commit 4b7268d4eb
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
2 changed files with 28 additions and 0 deletions

View file

@ -1,3 +1,6 @@
# Examples
- [Recommended usage with NTP time synchronization](example.py)
- [Minimal example](minimal.py)[^warning-date]
[^warning-date]: Warning: this will send an email with a very wrong date if the time was not synchronized on the device.

25
examples/minimal.py Normal file
View file

@ -0,0 +1,25 @@
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!\n")
# Send message
client.send()
client.quit()