Sample code for 30+ languages & platforms
Lua

Send email using smtp.gmail.com with SSL (port 465).

Send email using smtp.gmail.com with SSL (port 465).

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.

-- The mailman object is used for sending and receiving email.
local mailman = chilkat.MailMan.new()

-- Set the SMTP server.
mailman.smtp_host = "smtp.gmail.com"

mailman.smtp_username = "mySmtpLogin"
mailman.smtp_password = "myPassword"

mailman.smtp_ssl = true
mailman.smtp_port = 465

-- Create a new email object
local email = chilkat.Email.new()

email.subject = "This is a test"
email.body = "This is a test"
email.from = "Chilkat Support <chilkat.support@gmail.com>"
local success = email:add_to("Chilkat Admin", "admin@chilkatsoft.com")

success = mailman:send_email(email)
if not success then
    print(mailman.last_error_text)
    return
end

success = mailman:close_smtp_connection()
if not success then
    print("Connection to SMTP server not closed cleanly.")
end

print("Mail Sent!")