Send Email Notifications in Rails Development – WowKhmer

Send Email Notifications in Rails Development

Oct 02nd 2011

When there are features in your application that deal with sending email to users(eg. account activation, forget password). When you would like to test those features in your Rails development environment, then you probably go to running server’s log to copy generated links in the sending email, and how about when your managers would like to test them as well, then do they know how to go to the log to copy the links? And some other people use their real email addresses(eg. gmail) to receive the emails. Would you ever though any easier solution?

1. MailCatcher

MailCatcher is a Ruby gem from Samuel Cochran. MailCatcher runs a super simple SMTP server which catches any message sent to it to display in a web interface.

How

$ gem install mailcatcher$ mailcatcher -fStarting MailCatcher==> smtp://127.0.0.1:1025==> http://127.0.0.1:1080

Then set the delivery method in config/environments/development.rb

config.action_mailer.delivery_method = :smtpconfig.action_mailer.smtp_settings = { :host => "localhost", :port => 1025 }

2. Letter Opener

Letter Opener is a Ruby gem from Ryan Bates who run the awesome railscasts. Letter Opener previews emails in the browser instead of sending it.

How

First add the gem to your development environment and run the bundle command to install it.

gem "letter_opener", :group => :development

Then set the delivery method in config/environments/development.rb

config.action_mailer.delivery_method = :letter_opener

Note: While I write this article, there are some people face an issue with nothing happen when sending email out. I found the problem because of Launchy dependency gem version. Because @ryanb hasn’t specified version of Launchy dependency gem in gemspec file, then it won’t install the new Launchy version if there is any old versions in local gems. I already sent a pull request, and hope it will fix soon.

3. MockSMTP

The third option that I haven’t tried myself either is MockSMTP. MockSMTP is a native Mac application that embeds its own SMTP server.

HOW

There is a help page to tell you how to could configure your Rails applications to use with MockSMTP.

Add Warble Untuk Create .war pada Rails Anda, di Netbeans

Seringkali telat!Ya telat banget untuk nambah warble pada project rails yang sedang digarapEntah warble nya yang belum diinstall ato malah blum didonlot ..Bagi semua yang memang bekerja di environtment JRuby tentu sudah tidak bingung lagi dengan warble,Warble dapat membuat .war untuk aplikasi rails, sehingga dapat didpeloy pada server J2EE, (kadang itu memang mempermudah deployement rails) :DOk langsung saja, tanpa basa basi ..Jika project netbeans rails anda belum ada warble maka lakukan perintah ini :

  • Pergi ke root folder rails project
  • <path-to-jruby-bin-folder>jruby -S warble pluginize
  • Klik tombol Refresh Tasks pada menu run / debug rake
    Media_httpblogitsacid_lyfmq

Udah deh, langsung bisa buat .war pake rake task..Semoga mengobati luka juragan semua….