Ruby on Rails邮件程序没有在开发模式下发送电子邮件

时间:2021-07-22 10:46:05

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

我有一个Ruby on Rails应用程序,它有一个简单的mailer:

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:

我的action_mailer设置如下:

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

1 个解决方案

#1


9  

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

在开发中默认不发送邮件。要启用这个功能,您应该调整开发。rb:

config.action_mailer.perform_deliveries = true

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

还可以启用config.action_mailer。raise_delivery_errors = true以提高交付错误。

UPDATE

更新

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

当提供无效的电子邮件时,它被证明是缺省的,不会引起问题。

#1


9  

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

在开发中默认不发送邮件。要启用这个功能,您应该调整开发。rb:

config.action_mailer.perform_deliveries = true

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

还可以启用config.action_mailer。raise_delivery_errors = true以提高交付错误。

UPDATE

更新

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

当提供无效的电子邮件时,它被证明是缺省的,不会引起问题。