factory_girl

https://github.com/thoughtbot/factory_girl

Ruby

A library for setting up Ruby objects as test data.

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.

Source | Google | Stack overflow

Edit

git clone [email protected]:thoughtbot/factory_girl.git

cd factory_girl

open

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Mail--Message-errors-for-pr


# Commit to git

git add git commit -m "better docs for Mail::Message#errors"


# Open pull request

gem 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!