Rails smtp 邮件出错时

看看下面的提示
553 You are not authorized to send mail, authentication is required
下面是配置的过程,说明已经没有问题了。只是,往往这么提示意味着,在smtp setting里的邮件地址设置,和发邮件时的发件人邮件地址不一致。smtp服务器就不允许发送了
development.rb
config.action_mailer.raise_delivery_errors = true

config.action_mailer.delivery_method = :sendmail

config.action_mailer.smtp_settings = {
:address => "smtp.126.com",
:user_name => "xuejunjun0825@126.com",
:password => "xxxxxx",
:authentication => :login,
#:domain => "www.126.com"
}

models

class Ordermail < ActionMailer::Base
def simple_message(recipient)
@subject = "Text_test"
@body = "1111111111111111111111"
@recipients = recipient
@from = "xxxx@liandisys.com.cn"
@sent_on = Time.now
#@cc = "xxxxx@liandisys.com.cn"
@bcc = "xxxx@liandisys.com.cn"
end
end


#control
Ordermail.deliver_simple_message("xue_jj0825@hotmail.com")


运行结果:
[quote]553 You are not authorized to send mail, authentication is required

D:/ruby/lib/ruby/1.8/net/smtp.rb:680:in `check_response'
D:/ruby/lib/ruby/1.8/net/smtp.rb:653:in `getok'
D:/ruby/lib/ruby/1.8/net/smtp.rb:631:in `mailfrom'
D:/ruby/lib/ruby/1.8/net/smtp.rb:544:in `send0'
D:/ruby/lib/ruby/1.8/net/smtp.rb:472:in `sendmail'
D:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/base.rb:588:in `perform_delivery_smtp'
D:/ruby/lib/ruby/1.8/net/smtp.rb:379:in `start'
D:/ruby/lib/ruby/1.8/net/smtp.rb:316:in `start'
D:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/base.rb:586:in `perform_delivery_smtp'
D:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/base.rb:469:in `__send__'
D:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/base.rb:469:in `deliver!'
D:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/base.rb:352:in `method_missing'
app/controllers/todos_controller.rb:17:in `index' [/quote]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值