http://blog.scimpr.com/2012/09/15/railsでメール送信をテスト〜actionmailer/
$ rails new mailtest $ rails g scaffold user name email $ rails g mailer my_mailer hello
config/environments/develompent.rb
以下はGmailを使う時の設定(メールアドレスは別ドメインを指定している)
ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = { :address => "smtp.gmail.com", :port => 587, :authentication => :login, :user_name => "user@example.com", :password => "*********", :domain => "example.com" }
app/mailer/my_mailer
これがコントローラ的なもの(クラス名はMyMailerとなる)
デフォルトアクションとしてhelloを生成しているのでこれをいじる。
app/vier/my_mailer/hello.txt.erbのレイアウトを変更する
これが実際に送られる文面となる。
あとはどっかのコントローラからMyMailer.helloとしてアクションを呼ぶ。
MyMailer.hello.deliverで実際に送信する。