【问题标题】:Devise confirmation emails are not arriving. How do I properly configure it?未收到设计确认电子邮件。如何正确配置它?
【发布时间】:2011-06-02 13:25:43
【问题描述】:

Action Mailer 在development.rb中配置如下:

config.action_mailer.delivery_method       = :sendmail
config.action_mailer.perform_deliveries    = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options   = { :host => 'localhost:3000' }

根据 Rails 指南和我在互联网上找到的所有额外信息,这应该可以工作。当我搜索我的具体问题时,我主要找到了 SMTP 配置的解决方案。

我错过了什么?

更新:

出于某种原因,我所有的电子邮件都被发送到/var/mail/root。

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 devise sendmail actionmailer


    【解决方案1】:

    在您的开发机器上,您是否安装了“sendmail”程序?在命令行上试试这个:

    which sendmail
    

    如果我是你,我不会在开发模式下发送电子邮件,但如果你确实想这样做,请注册一个 gmail.com 帐户并使用它:

    config.action_mailer.delivery_method = :smtp
    
    config.action_mailer.smtp_settings = {
      :enable_starttls_auto => true,
      :address => "smtp.gmail.com",
      :port => 587,
      :domain => "gmail.com",
      :authentication => :login,
      :user_name => "<your username>@gmail.com",
      :password => "<your password>",
    }
    

    【讨论】:

    • 是的,我的机器上有 sendmail; which sendmail 输出 /usr/sbin/sendmail。我确实读过 Action Mailer 的 deliveries 数组。如何在开发中使用它?
    • 这可能不是因为配置 - 发送代码是什么样的? /var/log/mail.log 中有什么?
    • 啊,是的 - 你不会有一个发件人策略框架。看看sendgrid.com 并使用 SMTP。
    • 有没有办法加密密码?
    • @scientiffic 通常我会将密码放在生产服务器上的环境变量和我的仓库中的工头 .env 文件中。如果你将它存储在不受信任的地方,你可以使用github.com/mdp/gibberish 来加密/解密
    【解决方案2】:

    不能是使用sendmail的某个域
    所以修改devise.rb中的配置

    config.mailer_sender = "no-reply@other-domain.com"
    

    查看下面的邮件日志

    tail -f /var/log/mail.log 
    

    祝你好运

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-04
      • 2012-03-09
      • 2011-08-22
      • 1970-01-01
      • 2016-02-23
      • 2012-03-10
      • 2016-02-14
      • 1970-01-01
      相关资源
      最近更新 更多