Ruby Requires Chilkat v11.0.0+
Ruby
Trace the Received headers on a delivered message
See more Email Object Examples
Each relay prepends its Received field. Read the trace from top to bottom for newest to oldest, and interpret fields in light of the relays you trust. An unsent local draft can have no trace headers.
Chilkat Ruby Downloads
require 'chilkat'
success = false
# Assumes Chilkat is unlocked. See Global Unlock Sample.
email = Chilkat::CkEmail.new()
success = email.LoadEml("received.eml")
if (success != true)
print email.lastErrorText() + "\n";
exit
end
name = Chilkat::CkStringBuilder.new()
hops = 0
i = 0
while (i < email.get_NumHeaderFields())
name.SetString(email.getHeaderFieldName(i))
if (name.ContentsEqual("Received",false) == true)
hops = hops + 1
print "Hop " + hops.to_s() + ": " + email.getHeaderFieldValue(i) + "\n";
end
i = i + 1
end
print "Received fields: " + hops.to_s() + "\n";