Lua
Lua
Send Email using smtp-mail.outlook.com with Password Authentication
See more SMTP Examples
Demonstrates how to send an email using smtp-mail.outlook.com using password authentication.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local mailman = chilkat.MailMan.new()
mailman.smtp_host = "smtp-mail.outlook.com"
mailman.smtp_port = 587
mailman.start_tls = true
-- Set the SMTP login/password
mailman.smtp_username = "OFFICE365_USERNAME"
mailman.smtp_password = "OFFICE365_PASSWORD"
-- Create a new email object
local email = chilkat.Email.new()
email.subject = "This is a test"
email.body = "This is a test"
email.from = "My Name <my_office365_email@outlook.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
print(mailman.smtp_session_log)
success = mailman:close_smtp_connection()
if not success then
print("Connection to SMTP server not closed cleanly.")
end
print("Email Sent!")