开发者

rails send empty message

Mailer:

class CustomerHistoryMailer < ActionMailer::Base
  default :from => "notifications@example.com"
  def log_email(to)
    mail(:to => to,
         :subject => 'Report')
  end
end

Controller:

class Admin::ReportsController < ApplicationController
  def ind开发者_JAVA百科ex
    CustomerHistoryMailer.log_email("me@example.com").deliver
  end
end

View (app/views/customer_history_mailer/log_email.text.erb):

Hello, world!

In my mailbox I receive empty message with right subject. Why?


Is it possible that you have generated a .html.rb view as well, and rails is detecting both, thus sending a multipart message (being the HTML empty) thus you are not seeing anything because your email client defaults to the HTML view?

Can you verify that?

--- What about specifying the order for html/text in the multipart msg?

class UserMailer < ActionMailer::Base
  def welcome_email(user)
    @user = user
    @url  = user_url(@user)
    mail(:to => user.email,
         :subject => "Welcome to My Awesome Site") do |format|
      format.html
      format.text
    end
  end
end


I removed config.action_mailer.deprecation = :log line from config/environments/development.rb and it works now.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜