2

I have a Ruby on Rails application with simple mailer which looks like this:

class EventMailer < ActionMailer::Base

  default from: "example.com"

  def welcome_email(event, customer)
    @event = event
    @customer = customer
    mail :subject => "Test", :to => @customer.email
  end
end

My action_mailer settings looks like this:

config.action_mailer.smtp_settings = {
    :address   => "smtp.mandrillapp.com",
    :port      => 587, # ports 587 and 2525 are also supported with STARTTLS
    :enable_starttls_auto => true, # detects and uses STARTTLS
    :user_name => "my_email",
    :password  => "my_password", # SMTP password is any valid API key
    :authentication => 'login', # Mandrill supports 'plain' or 'login'
    :domain => 'yourdomain.com', # your domain to identify your server when connecting
  }

I have also customer registration with devise and it sends email properly. But when I try to run in my console:

EventMailer.welcome_email(Event.last, Customer.last).deliver

It does not deliver email. What can be wrong? I have no ideas...

Edit: Rest of my config

  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
Mateusz Urbański
  • 7,352
  • 15
  • 68
  • 133

1 Answers1

11

Mail is not sent in development by default. To enable this you should tweak your development.rb like this:

config.action_mailer.perform_deliveries = true

You may also enable config.action_mailer.raise_delivery_errors = true to raise delivery errors.

UPDATE

It turned out to be the default from causing the problems as the invalid e-mail was provided.