【发布时间】:2014-12-05 08:19:37
【问题描述】:
我有一个带有简单邮件程序的 Ruby on Rails 应用程序,如下所示:
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
我的 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
}
我也有客户注册,它可以正确发送电子邮件。但是当我尝试在我的控制台中运行时:
EventMailer.welcome_email(Event.last, Customer.last).deliver
它不发送电子邮件。有什么问题?我没有想法...
编辑: 我的其余配置
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
【问题讨论】:
-
您的控制台有错误吗?
-
不,控制台中没有任何错误...
-
顺便说一句,您的
default from似乎很奇怪。应该放一封电子邮件。 -
哦,这种事情经常发生 :) 很高兴它有帮助!
标签: ruby-on-rails ruby actionmailer