send_intermediate_email_with_smtp

send_intermediate_email_with_smtp(
    smtp_host,
    smtp_port,
    username,
    password,
    i_email,
    security=Literal['tls', 'ssl', 'smtp'],
)

Send an Intermediate Email object via SMTP.

Parameters

smtp_host : str

SMTP server hostname (e.g., “smtp.example.com”)

smtp_port : int

SMTP server port (typically 587 for TLS, 465 for SSL, 25 for plain SMTP)

username : str

SMTP account username for authentication

password : str

SMTP account password

i_email : IntermediateEmail

IntermediateEmail object containing the email content and attachments

security : str = Literal['tls', 'ssl', 'smtp']

Security protocol to use: “tls” (STARTTLS), “ssl” (SSL/TLS), or “smtp” (plain SMTP). Default is “tls”.

Returns

: None

The function sends an email but doesn’t return a value

Raises

: ValueError

If security parameter is not one of “tls”, “ssl”, or “smtp”

Examples

email = IntermediateEmail(
    html="<p>Hello world</p>",
    subject="Test Email",
    recipients=["user@example.com"],
)

# TLS connection (port 587) - recommended
send_intermediate_email_with_smtp(
    "smtp.example.com",
    587,
    "user@example.com",
    "password123",
    email,
    security="tls"
)

# SSL connection (port 465)
send_intermediate_email_with_smtp(
    "smtp.example.com",
    465,
    "user@example.com",
    "password123",
    email,
    security="ssl"
)

# Plain SMTP (port 25) - insecure, for testing only
send_intermediate_email_with_smtp(
    "127.0.0.1",
    8025,
    "test@example.com",
    "password",
    email,
    security="smtp"
)