Kir
Kir

Reputation: 8111

rails send empty message

Mailer:

class CustomerHistoryMailer < ActionMailer::Base
  default :from => "[email protected]"
  def log_email(to)
    mail(:to => to,
         :subject => 'Report')
  end
end

Controller:

class Admin::ReportsController < ApplicationController
  def index
    CustomerHistoryMailer.log_email("[email protected]").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?

Upvotes: 1

Views: 919

Answers (2)

Kir
Kir

Reputation: 8111

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

Upvotes: 0

SomeDudeSomewhere
SomeDudeSomewhere

Reputation: 3940

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

Upvotes: 2

Related Questions