TMail Meta Data Functionality

Allows you to include extra data within the body of e-mail messages for use in automated parsing through TMail.

Settings

If you need to override the default scanner you can run this:

TMail::Metas.scanner = /Metas\((.*)\)/
TMail::Metas.scanner_options = {:seperator => ':', :group_seperator => ','}

# which will look for this:
# Metas(project_id:12,type:message)

Example

%w{pp rubygems tmail tmail_metas}.each { |lib| require lib }

EMAIL = "To: [email protected]\nFrom: [email protected]\nSubject: This is my automated email\n\nThis is an email which will be automatically handled by a ruby script!\nThe body will be stripped of these meta tags while they are made available\nin the mail.metas hash.\n\n{{project_id=12345&category=Incoming Emails&create=message}}\n\n"

mail = TMail::Mail.parse(EMAIL)

pp mail.metas # => {"category"=>"Incoming Emails", "project_id"=>"12345", "create"=>"message"}
pp mail.body  # => (body with the {{...}} metas stripped)