2015-07-21 45 views
0

我无法让我的邮件程序在开发环境中工作。 这是我在development.rb配置:不在本地环境发送邮件

config.action_mailer.default_url_options = { host: 'localhost:3000' } 
config.action_mailer.perform_deliveries = true 

config.action_mailer.delivery_method = :smtp 
config.action_mailer.smtp_settings = { 
    address: 'smtp.mandrillapp.com', 
    port: 587, 
    enable_starttls_auto: true, 
    user_name: '[email protected], 
    password: 'mypassword, 
    authentication: 'login', 
    domain: 'mandrill.com' 
} 

我的邮件方法:

class InformationRequestMailer < ActionMailer::Base 
    def information_request(operator, ref, property_url, contact_info) 
    @operator = operator 
    @property_url = property_url 
    mail(to: operator.email, subject: t("information_request_mailer.subject", property_ref: ref)) 
    end 
end 

在这里,我称之为:

InformationRequestMailer.delay.information_request(
    operator: operator, 
    ref: ref, 
    property_url: property_url, 
    contact_info: params[:contact_info] 
) 

在此先感谢。

+0

您是否在日志中发现任何错误?我也会假设你在配置的密码字段中输入了''''。 –

+0

什么是OS dev env正在运行?它有'sendmail'或者像是已安装的? – mudasobwa

+0

@JustinWood,我完全没有错。是的,密码有相应的结尾'。我会在这里解决这个问题.. – ntonnelier

回答

0

如果你有一个当前Rails版本,这应该工作:

InformationRequestMailer.information_request(
    operator: operator, 
    ref: ref, 
    property_url: property_url, 
    contact_info: params[:contact_info] 
).deliver_later 

既然你要使用的延期交货,你需要有你的队列运行工人。

+0

谢谢@Yury,但它不采用这种方法。应该是我上面描述的方式。我使用rails 4.1.1 – ntonnelier

+0

@ntonnelier好吧,它没有'延迟'工作吗? –

+0

不,@Yury,它不。 – ntonnelier