Help us understand the problem. What is going on with this article?

Padrino で Letter Opener を使う

More than 5 years have passed since last update.

メール送信機能を実装したいんだけど、いちいち飛んできたメールを確認するのが面倒な場合に、使うと便利な letter_opener

メールの内容がローカル環境にファイルとして生成され、ブラウザ上で確認できるようになります。

つかいかた

$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.1]
$ padrino -v
Padrino v. 0.11.2
$
$ cd sample_project

Padrino Plugin でサクッと使えます

$ padrino g plugin letter_opener
$ bundle install

これで、

$ vim app/app.rb
app/app.rb
module SampleProject
  class App < Padrino::Application
    # 省略

    get '/mail' do
      email do
      from    'foo@example.com'
        to      'bar@example.com'
        subject 'Welcome!'
        body    'Hello! Hello!'
      end
    end

    # 省略
  end
end

こんな感じのがあったとすると、ブラウザで /mail を叩けばメールが別ウィンドウで開くようになります。

じぶんでやる

$ vim Gemfile
gem "letter_opener", :group => :development
$ bundle install
$ vim config/apps.rb
config/apps.rb
Padrino.configure_apps do
  # …
  if Padrino.env == :development
    set :delivery_method, {
      LetterOpener::DeliveryMethod => {
        location: Padrino.root('tmp/letter_opener')
      }
    }
  end
end
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away