Rails ActionMailer receive method does nothing

203 views Asked by At

I'm following the Rails official doc about action mailer receive method and testing with the rails runner 'UserMailer.receive(STDIN.read)' command but nothing happens.

class UserMailer < ActionMailer::Base
  add_template_helper EmailHelper
  default from: "[email protected]"

  def user_created(params)
    @user = User.find params[0]
    @creator = User.find params[1]
    if @user && @creator
        mail(to: @user.email, subject: "......").deliver
    else
        logger.info "......"
    end
  end

  def receive(email)
    puts YAML::dump email
  end
end

Here's the detail about my Rails app

[email protected]
[email protected]

The UserMailer actually sends emails but can not receive them. Any ideas?

1

There are 1 answers

0
Mel On

I think you want to refer to Action Mailer Basics Guide: http://guides.rubyonrails.org/action_mailer_basics.html#receiving-emails

I'm interpreting their suggestion to mean: Configure your mail server/process to "pipe into" a Rails runner script... That would account for the STDIN.read; the contents of the mail message would be passed into the script.

HTH.