设计确认电子邮件未到达.我该如何正确配置它?

Mat*_*ira 4 sendmail ruby-on-rails actionmailer devise ruby-on-rails-3

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' }
Run Code Online (Sandbox Code Playgroud)

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

我错过了什么?

更新:

/var/mail/root由于某种原因,我的所有电子邮件都已发送给我.

ste*_*tef 8

在您的开发机器上,您是否安装了"sendmail"程序?在命令行上尝试:

which sendmail
Run Code Online (Sandbox Code Playgroud)

如果我是你,我不会在开发模式下发送电子邮件,但如果你想这样做,请注册一个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>",
}
Run Code Online (Sandbox Code Playgroud)

  • @scientiffic通常我会将密码放在生产服务器上的环境变量和我的仓库中的工头.env文件中.如果您将它存储在不受信任的地方,您可以使用https://github.com/mdp/gibberish加密/解密 (2认同)