Lua Requires Chilkat v11.0.0+
Lua
Example: Email.GetDsnInfo method
See more Email Object Examples
Demonstrates how to call the GetDsnInfo method.Chilkat Lua Downloads
local chilkat = require("chilkat")
local email = chilkat.Email.new()
local success = email:load_eml("qa_data/eml/sample_multipart_report.eml")
if not success then
print(email.last_error_text)
return
end
local json = chilkat.JsonObject.new()
success = email:get_dsn_info(json)
if not success then
print(email.last_error_text)
return
end
json.emit_compact = false
print(json:emit())
-- Sample output:
-- {
-- "reporting-mta": "dns; Exchange2016.example.com",
-- "final-recipient": [
-- "herb.butterworth1247692846@gmail.com"
-- ],
-- "action": "failed",
-- "status": "5.1.1",
-- "remote-mta": "dns; mx.google.com",
-- "x-supplementary-info": "<mx.google.com #5.1.1 smtp;550-5.1.1 The email account that you tried to reach does not exist. Please try 550-5.1.1 double-checking the recipient's email address for typos or 550-5.1.1 unnecessary spaces. Learn more at 550 5.1.1 https://support.google.com/mail/?p=NoSuchUser o8-20020a056870968800b001b55816bea9si2188132oaq.70 - gsmtp>",
-- "x-display-name": "herb.butterworth1247692846@gmail.com"
-- }
-- Code for parsing the JSON:
local strVal = ""
local reporting_mta = json:string_of("reporting-mta")
local action = json:string_of("action")
local status = json:string_of("status")
local remote_mta = json:string_of("remote-mta")
local x_supplementary_info = json:string_of("x-supplementary-info")
local x_display_name = json:string_of("x-display-name")
local i = 0
local count = json:size_of_array("final-recipient")
while i < count do
json.i = i
strVal = json:string_of("final-recipient[i]")
i = i + 1
end