【问题标题】:sendmail with RoR: not receiving mails带有 RoR 的 sendmail:不接收邮件
【发布时间】:2015-01-23 11:21:27
【问题描述】:

我在我的 Rails 应用程序中使用 sendmail。配置如下,

config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.default_url_options = { :host => 'localhost' }
  config.action_mailer.default_options = {from: 'no-reply@example.com'}
  config.action_mailer.delivery_method = :sendmail

当我重新启动我的 apache2 服务器和 sendmail 服务时,我会收到一封邮件(一次)。但是,如果稍后我尝试发送邮件,它会显示状态为 200-ok,但我不会收到任何邮件。

仅供参考:

即使localhost:3000也发现了同样的问题

下面也是我的 mail.log 输出

Nov 25 17:58:02 dosysnet267 sendmail[1602]: sAPCS2X3001602: Authentication-Warning: dosysnet267.dreamorbit.in: DREAMORBIT\\karthik.ds set sender to no-reply@gmail.com using -f
Nov 25 17:58:02 dosysnet267 sendmail[1602]: sAPCS2X3001602: from=no-reply@gmail.com, size=473, class=0, nrcpts=1, msgid=<547475d2aa8c3_5dc181896c66978@dosysnet267.mail>, relay=DREAMORBIT\\karthik.ds@localhost
Nov 25 17:58:03 dosysnet267 sm-mta[1604]: sAPCS2bg001604: from=<no-reply@gmail.com>, size=774, class=0, nrcpts=1, msgid=<547475d2aa8c3_5dc181896c66978@dosysnet267.mail>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Nov 25 17:58:03 dosysnet267 sendmail[1602]: sAPCS2X3001602: to=karthik.ds@example.com, ctladdr=no-reply@gmail.com (1200096887/1200095745), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30473, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (sAPCS2bg001604 Message accepted for delivery)
Nov 25 17:58:05 dosysnet267 sm-mta[1609]: sAPCS2bg001604: to=<karthik.ds@example.com>, delay=00:00:03, xdelay=00:00:02, mailer=esmtp, pri=120774, relay=example.com. [174.136.95.75], dsn=2.0.0, stat=Sent (OK)

有什么想法吗?

【问题讨论】:

  • 您可以分享发送该电子邮件时调用的代码吗?
  • UserMailer.welcome_user(self).deliver!
  • 哦!对我来说似乎没问题。顺便说一句,你检查你的垃圾邮件文件夹了吗?
  • 感谢您的回复。是的,我查过了,但没有邮件。
  • 好吧,我似乎无能为力。对不起。

标签: ruby-on-rails email sendmail


【解决方案1】:

感谢您调查此问题。它工作正常。由于邮箱问题,我无法接收邮件。

【讨论】:

    【解决方案2】:

    当我在测试 Rails 应用程序时需要发送电子邮件时,我是否会在开发文件中使用此代码。然后只需填写您的 gmail 凭据即可。然后,rails 应用程序将使用您的 gmail 帐户通过 gmail 发送电子邮件。

    config/environments/development.rb
    
    config.action_mailer.raise_delivery_errors = true
    config.action_mailer.delivery_method = :smtp
    config.action_mailer.smtp_settings = {
    :address              => "smtp.gmail.com",
    :port                 => 587,
    :domain               => 'gmail.com',
    :user_name            => 'youremail@gmail.com',
    :password             => 'yourpassword',
    :authentication       => 'plain',
    :enable_starttls_auto => true  }
    config.action_mailer.default_url_options = { :host => "localhost:3000" } 
    

    【讨论】:

      猜你喜欢
      • 2016-01-11
      • 2011-09-21
      • 2011-12-25
      • 2016-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-13
      相关资源
      最近更新 更多