rails:action_mailer
目次
ActionMailer
Railsのメール送信のクラス。
メールはUTF-8になってしまうが、Ruby-Gettextを入れるとiso-2022-jpで送信されるようになる。
作り方
$ script/generate mailer TestMailer notify_test greet_birthday
TestMailerというモデルが作られる。TestMailerにはnotify_test greet_birthdayというメソッドが作られ、メソッドに対応するメール本文のerbファイルが作られる。
設定
smtpサーバの設定が必要
sendmailを使う(ここではeximを使用)
ActionMailer::Base.delivery_method = :sendmail
ActionMailer::Base.smtp_settings = {
:location => "/opt/local/bin/exim"
:arguments => "-t -i"
}
SMTPサーバで中継するならば
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "no-smtp.paulownia.jp",
:port => 25,
:authentication => :plain,
:user_name => "paulownia",
:password => "xxxxxxxx",
:domain => "paulownia.jp"
}
rails/action_mailer.txt · 最終更新: by 127.0.0.1