2017-04-03 47 views
0

我有一个动作邮件的方法是这样的:的ActionMailer作用的生产服务器上的不同

def mail 
@receiver = User.where(status: 2).pluck(:email) 
mail(bcc:@receiver, to: "[email protected]") 
end 

application.yml看起来是这样的:

SMTP_ADDRESS: 'smtp.gmail.com' 
SMTP_PORT: 587 
SMTP_HOST: 'localhost:3000' 
SMTP_DOMAIN: 'localhost:3000' 
SMTP_USERNAME: '[email protected]' 
SMTP_PASSWORD: 'xxxxx' 
SUPER_ADMIN_EMAIL: '[email protected]' 

developmet.rb样子此:

config.action_mailer.asset_host = ENV["SMTP_HOST"] 
    # config.action_mailer.delivery_method = :letter_opener 
    config.action_mailer.raise_delivery_errors = false 

    config.action_mailer.delivery_method = :smtp 
    config.action_mailer.smtp_settings = { 
    #Enter the smtp provider here ex: smtp.mandrillapp.com 
    address: ENV["SMTP_ADDRESS"], 
    port: ENV['SMTP_PORT'].to_i, 
    #Enter the smtp domain here ex: vendaxo.com 
    domain: ENV["SMTP_DOMAIN"], 
    #Enter the user name for smtp provider here 
    user_name: ENV["SMTP_USERNAME"], 
    #Enter the password for smtp provider here 
    password: ENV["SMTP_PASSWORD"], 
    authentication: 'plain', 
    enable_starttls_auto: true 

收件人保存在BCC中,但“[email protected]”将能够看到BCCd接收者。当我从本地主机发送邮件时,这工作正常。当收件人发送电子邮件时,所有人都在密件抄送中,一个“[email protected]”能够看到所有的收件人。

但是当我做生产服务器具有相似application.yml配置更改主机和端口[email protected]没有得到BCCD接收的电子邮件,同样的事情。

+0

可能会有所帮助https://www.sitepoint.com/deliver-the-mail-with-amazon-ses-and-rails/ –

回答

0

我想,如果你在AWS EC2上运行的生产服务器(可能是其他供应商也是如此),每次你做一些更改application.yml或任何其他共享文件时,您需要重新启动应用服务器以便应用更改后的配置。在我的情况下,我不得不重新启动PUMA,并且一个默认电子邮件开始获得BCCd电子邮件ID。

相关问题