Rails Action Mailer 无法发邮件

ziu · 2014年03月18日 · 最后由 ruby_sky 回复于 2014年03月27日 · 3846 次阅读

设置 action mailer 发不出邮件 development.rb:

config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address:        "smtp.163.com",
    port:           25, 
    domain:         "163.com",
    authentication: :login,
    user_name:      "[email protected]",
    password:       "password",
    enable_starttls_auto: true
  }

enable_starttls_auto 我换过 false,还是不行吧 notifiler.rb

class Notifier < ActionMailer::Base
  default from: "[email protected]"

  def order_received(order)
    @order=order
    mail :to=>order.email, subject:'Lumos'
  end

调用 deliver() 发送 orders_controller.rb

Notifier.order_received(@order).deliver

log 信息: Sent mail to [email protected] (25831.2ms) Date: Tue, 18 Mar 2014 21:44:43 +0800 From: [email protected] To: [email protected] Message-ID: <[email protected]> Subject: Lumos Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit

Notifier#order_received

Hi, find me in app/views/app/views/notifier/order_received.text.erb

Dear casd HeHe. You ordered the following items: 1 x HIMYM We'll send you a separate e-mail when your order ships.

Redirected to http://0.0.0.0:3000/store/index Completed 302 Found in 26430ms (ActiveRecord: 528.0ms)

问题出在哪?怎么改? 谢谢。

日志里没有记录错误信息?忘了调用 .deliver() 方法了?

#1 楼 @lululau 调用了。日志信息我贴上去了。

#2 楼 @ziu 把 from 换成你的真实的 163 邮箱试试

#3 楼 @lululau 好了,太感谢了。 但“from“参数不是只是个参数,显示发件人的吗?不可以设成其他内容吗? 实际发信用的邮箱不是在 config 里设好了吗?

想起前几天 QQ 邮箱的一个神坑:在完全不提示的情况下,增加了一条规则把我发过去的邮件删除了。害我一下午。。

垃圾邮箱查查。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号