Rails 3.2.3アプリケーションが正常に動作し、デバイスが作成したメールメッセージを登録確認およびパスワード忘れメールメッセージとして配信し、新しいパスワードを設定します。
ただし、メール通知を配信したい別の場所があります。
これが私のNotifier
モデルです。
# encoding: utf-8
class Notifier < ActionMailer::Base
default from: "no-reply@domain.com"
default to: "admin@domain.com"
def new_post_submitted(post)
@post = post
mail(subject: "Anúncio enviado: #{@post.title}")
end
def new_message(message)
@message = message
mail(subject: "Mensagem de contato: #{@message.subject}")
end
end
コントローラーは次のように呼び出します。
def create
@message = Message.new(params[:message])
if @message.valid?
Notifier.new_message(@message).deliver
redirect_to(root_path, :notice => "Obrigado. Sua Mensagem enviada com sucesso")
else
flash.now.alert = "Por favor preencha todos os campos."
render :new
end
end
ログ出力には、配信されたことが示されています。
Started POST "/contato" for 187.57.102.168 at 2012-08-31 11:28:51 +0900
Processing by ContactController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"TVdmDYCA4x3JVi+9pMcpY7OSU/P1lE9enLiFJlK9W1M=", "message"=>{"name"=>"kleber", "email"=>"test@gmail.com", "subject"=>"teste", "body"=>"hello there"}, "commit"=>"Enviar"}
Rendered notifier/new_message.html.erb (0.1ms)
Sent mail to admin@domain.com (152ms)
Redirected to http://www.domain.com/
Completed 302 Found in 158ms (ActiveRecord: 0.0ms)
そして、私のconfig/production.rb
ファイルの次の構成。
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "localhost",
:port => 25,
:domain => "domain.com",
:authentication => :login,
:user_name => "admin@domain.com",
:password => "mypassword",
:enable_starttls_auto => false
}
ここで何が起こっているのか手がかりはありますか?