Lua Requires Chilkat v11.0.0+
Lua
Send an email with a Bcc recipient using SMTP (live send)
See more Email Object Examples
Live send. Load the previously prepared with-attachments.eml, add a Bcc recipient, and pass the Email to MailMan.SendEmail. For a real test, use a relay you control, replace the sample sender and recipients (including the Bcc address) with test mailboxes, and obtain credentials from your application’s secret store.
Chilkat Lua Downloads
local chilkat = require("chilkat")
-- Assumes Chilkat is unlocked. See Global Unlock Sample.
local email = chilkat.Email.new()
local success = email:load_eml("with-attachments.eml")
if not success then
print(email.last_error_text)
return
end
-- Enable this option before adding a blind recipient to the message.
email.uncommon_options = "NoBccHeader"
success = email:add_bcc("Bcc recipient", "bcc@example.net")
if not success then
print(email.last_error_text)
return
end
local mail = chilkat.MailMan.new()
mail.smtp_host = "smtp.example.com"
mail.smtp_port = 465
mail.smtp_ssl = true
mail.require_ssl_cert_verify = true
mail.smtp_username = "MAIL_USER"
mail.smtp_password = "MAIL_PASSWORD"
success = mail:send_email(email)
if not success then
print(mail.last_error_text)
return
end
print("The SMTP relay accepted the message.")
success = mail:close_smtp_connection()
if not success then
print(mail.last_error_text)
return
end