我试过所有我能想到的用Rails 4.1.6(本地开发)发送电子邮件,但没有任何工作。使用邮戳我已经在我的development.rb和application.rb中如下:Rails 4 actionmailer不发送电子邮件
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.delivery_method = :postmark
config.action_mailer.postmark_settings = { :api_key => API_KEY }
config.action_mailer.perform_deliveries = true
和GMAIL我想:
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'gmail.com',
user_name: 'my_email',
password: 'my_password',
authentication: 'plain',
enable_starttls_auto: true }
我梅勒类看起来像这样:
class BusinessMailer < ActionMailer::Base
default from: "[email protected]"
def claim_business business
mail(
:subject => 'hello',
:to => '[email protected]',
:from => '[email protected]',
:html_body => '<strong>Hello John Doe<strong>',
:track_opens => 'true'
)
end
end
最后,我通过以下方式发送电子邮件:BusinessMailer.claim_business @business
当我触发claim_business
方法我在控制台中看到BusinessMailer#claim_business: processed outbound mail in 14.1ms
,没有错误消息。谁能告诉我我在这里失踪了什么?
添加'config.action_mailer.raise_delivery_errors = true',看看会发生什么。 – blelump 2014-11-04 15:12:21
@blelump我有,并没有得到任何额外的输出到控制台,只是标准的'处理出站邮件' – 2014-11-04 15:15:32
好吧,那么:'BusinessMailer.claim_business(@business).deliver'? – blelump 2014-11-04 15:16:32