`
wuhuizhong
  • 浏览: 681229 次
  • 性别: Icon_minigender_1
  • 来自: 中山
社区版块
存档分类
最新评论

Refinery 找回密码时报错:Net::SMTPFatalError (555 5.5.2 Syntax error.)

    博客分类:
  • ROR
阅读更多

设置 config/initializers/setup_mail.rb

 

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :domain               => "127.0.0.1",
  :user_name            => "gmailusername",
  :password             => "gmailpassword",  
  :authentication       => "plain",
  :enable_starttls_auto => true
}
 

development环境显示:

Sent mail to corey.erp@gmail.com (5737ms)
Date: Sun, 03 Apr 2011 18:07:27 +0800
from: "Company Name" <no-reply@>
To: corey.erp@gmail.com
Message-ID: <4d9846df326eb_288c57cd5f85836d@bogon.mail>
Subject: =?UTF-8?Q?=E5=AF=86=E7=A0=81=E9=87=8D=E7=BD=AE=E7=9A=84=E8=BF=9E=E6=8E=A5?=
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: base64

 

production显示:

Net::SMTPFatalError (555 5.5.2 Syntax error. s41sm5755581wfc.15):

 

解决:

修改refinerycms-authentication-0.9.9.11/app/mailers/user_mailer.rb

将其中<no-reply@#{domain}> 用可用的 email 替代。

 

針對局域網:

设置 config/initializers/setup_mail.rb

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
  :address              => "email.pyzs.com.cn",
  :port                 => 25,
  :domain               => "pyzs.com.cn",
  :user_name            => "username",
  :password             => "password",
  :authentication       => :login
}

ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.default_charset = "utf-8"
ActionMailer::Base.default_content_type = "text/html"

/app/mailers 目录下创建一个新的user_mailer.rb 文件:

class UserMailer < ActionMailer::Base

  def reset_notification(user, request)
    @user = user
    @url = edit_user_password_url(:host => request.host_with_port,
                                  :reset_password_token => @user.reset_password_token)

    domain = request.domain(RefinerySetting.find_or_set(:tld_length, 1))

    mail(:to => user.email,
         :subject => t('subject', :scope => 'user_mailer.reset_notification'),
         :from => "\"#{RefinerySetting[:site_name]}\" <huizhong.wu@pyzs.com.cn>")
  end

protected

  def url_prefix(request)
    "#{request.protocol}#{request.host_with_port}"
  end
end
 

 

 

参考:

 

http://cn.asciicasts.com/episodes/206-actionmailer-in-rails3
http://stackoverflow.com/questions/5298147/rails-3-email-sending-problem
http://blog.livedoor.jp/satoyansoft/archives/65456593.html
http://apidock.com/rails/ActionMailer/Base
http://qa.taobao.com/?p=11324

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics