Return to index

smtp functions

string = email_add_header(email_content, header_name, header_value)

top

Add a new header to email content before the body.

Example:

# Example for email_add_header
println email_add_header("Subject: Test\n\nBody", "From", "test@example.com")


string = email_base64_decode(encoded_text)

top

Decode base64 encoded text.

Example:

# Example for email_base64_decode
println email_base64_decode("SGVsbG8=")


string = email_base64_encode(text)

top

Encode text using base64 encoding.

Example:

# Example for email_base64_encode
println email_base64_encode("Hello")


[]string = email_extract_addresses(text)

top

Extract email addresses from text using regex pattern matching.

Example:

# Example for email_extract_addresses
println email_extract_addresses("test@example.com")


[]map = email_get_attachments(email_content)

top

Extract attachment information from email content string.

Example:

# Example for email_get_attachments
email = "From: test@example.com\nSubject: Test\nContent-Type: multipart/mixed; boundary=\"boundary\"\n\n--boundary\nContent-Type: text/plain\n\nHello\n--boundary\nContent-Type: application/octet-stream\nContent-Disposition: attachment; filename=\"test.txt\"\n\nFile content\n--boundary--"
println email_get_attachments(email)


string = email_get_body(email_content)

top

Extract email body from email content string (RFC compliant).

Example:

# Example for email_get_body
try
    println email_get_body("Subject: Test\n\nBody")
catch err
    println "Email parse failed"
endtry


map = email_parse_headers(email_content)

top

Parse email headers from email content string (RFC compliant).

Example:

# Example for email_parse_headers
email = "From: sender@example.com\nTo: recipient@example.com\nSubject: Test Email\n\nBody content"
println email_parse_headers(email)


string = email_process_template(template, variables)

top

Process email template by replacing placeholders with variable values.

Example:

# Example for email_process_template
template = "Hello {name}, your order #{order} is ready."
vars = map(.name "Alice", .order "12345")
println email_process_template(template, vars)


string = email_remove_header(email_content, header_name)

top

Remove a specific header from email content.

Example:

# Example for email_remove_header
email = "Subject: Test\nFrom: old@example.com\n\nBody content"
println email_remove_header(email, "From")


bool = email_validate(email)

top

Validate email address format.

Example:

# Example for email_validate
println email_validate("test@example.com")
println email_validate("invalid-email")


bool = smtp_send(server, from, to, subject, body)

top

Send email via SMTP without authentication.

Example:

# Example for smtp_send
try
    smtp_send("test@example.com", ["to@example.com"], "Subject", "Body")
catch err
    println "SMTP failed"
endtry


bool = smtp_send_with_attachments(server, from, to, subject, body, attachments)

top

Send email via SMTP with file attachments.

Example:

# Example for smtp_send_with_attachments
try
    smtp_send_with_attachments("test@example.com", ["to@example.com"], "Subject", "Body", ["file.txt"])
catch err
    println "SMTP failed"
endtry


bool = smtp_send_with_auth(server, username, password, from, to, subject, body)

top

Send email via SMTP with authentication.

Example:

# Example for smtp_send_with_auth
try
    smtp_send_with_auth("test@example.com", ["to@example.com"], "Subject", "Body", "user", "pass")
catch err
    println "SMTP failed"
endtry