Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
8
Help us understand the problem. What is going on with this article?
@tyabe

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
8
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  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
tyabe
Rubyが好きなソフトウェアエンジニア。Shibuya.rb
storesjp
インターネットビジネスの企画・開発・運営、マーケティング、プロモーション、コンテンツの企画・制作

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
8
Help us understand the problem. What is going on with this article?