https://github.com/mikel/mail
Ruby
A Really Ruby Mail Library
Mail::Message#errors
Returns a list of parser errors on the header, each field that had an error
will be reparsed as an unstructured field to preserve the data inside, but
will not be used for further processing.
It returns a nested array of [field_name, value, original_error_message]
per error found.
Example:
message = Mail.new("Content-Transfer-Encoding: weirdo\r\n")
message.errors.size #=> 1
message.errors.first[0] #=> "Content-Transfer-Encoding"
message.errors.first[1] #=> "weirdo"
message.errors.first[3] #=> <The original error message exception>
This is a good first defence on detecting spam by the way. Some spammers send
invalid emails to try and get email parsers to give up parsing them.Edit
git clone [email protected]:mikel/mail.git
cd mail
open lib/mail/message.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Mail--Message-errors-for-pr
# Commit to gitgit add lib/mail/message.rbgit commit -m "better docs for Mail::Message#errors"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-Mail--Message-errors-for-pr
hub pull-request
# Celebrate!