devise

https://github.com/plataformatec/devise

Ruby

Flexible authentication solution for Rails with Warden.

Mail.new

Allows you to create a new Mail::Message object.

You can make an email via passing a string or passing a block.

For example, the following two examples will create the same email
message:

Creating via a string:

 string = "To: [email protected]\r\n"
 string << "From: [email protected]\r\n"
 string << "Subject: This is an email\r\n"
 string << "\r\n"
 string << "This is the body"
 Mail.new(string)

Or creating via a block:

 message = Mail.new do
   to '[email protected]'
   from '[email protected]'
   subject 'This is an email'
   body 'This is the body'
 end

Or creating via a hash (or hash like object):

 message = Mail.new({:to => '[email protected]',
                     'from' => '[email protected]',
                     :subject => 'This is an email',
                     :body => 'This is the body' })

Note, the hash keys can be strings or symbols, the passed in object
does not need to be a hash, it just needs to respond to :each_pair
and yield each key value pair.

As a side note, you can also create a new email through creating
a Mail::Message object directly and then passing in values via string,
symbol or direct method calls.  See Mail::Message for more information.

 mail = Mail.new
 mail.to = '[email protected]'
 mail[:from] = '[email protected]'
 mail['subject'] = 'This is an email'
 mail.body = 'This is the body'

Source | Google | Stack overflow

Edit

git clone [email protected]:plataformatec/devise.git

cd devise

open

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Mail-new-for-pr


# Commit to git

git add git commit -m "better docs for Mail.new"


# 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-new-for-pr

hub pull-request


# Celebrate!