Lua
Lua
Explicitly Connect to the SMTP Server
See more SMTP Examples
Demonstrates the Chilkat MailMan.SmtpConnect method, which explicitly connects to the SMTP server. If SSL/TLS is required by the current property settings, the secure TLS channel is established as part of connecting. This example opens the connection.
Background:
SmtpConnect performs just the connect (and TLS handshake) step, without authenticating — useful when you want fine-grained control over the connection lifecycle, or to separate connecting from authenticating (SmtpAuthenticate) for diagnostics. For everyday sending you don't need to call it: SendEmail connects automatically.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- Demonstrates the MailMan.SmtpConnect method, which explicitly connects to the SMTP server.
-- If SSL/TLS is required by the current property settings, the secure channel is established
-- as part of connecting.
local mailman = chilkat.MailMan.new()
-- Configure the SMTP server connection.
mailman.smtp_host = "smtp.example.com"
mailman.smtp_port = 465
mailman.smtp_ssl = true
-- Explicitly connect to the SMTP server (does not authenticate).
local success = mailman:smtp_connect()
if not success then
print(mailman.last_error_text)
return
end
print("Connected to the SMTP server.")