今天想实现发邮件时,接收到的邮件是显示发件人的名,而不是裸的邮件地址。
作法如:
@from = %(男人装 <noreply@nanrenainvren.com>)
不幸的是总报错:
01/09/09 22:26:50 ERROR smtpserver: Error parsing sender address: 男人装 <noreply@nanrenainvren.com>: Invalid character in local-part (user account) at position 4
但是
@recipients = %(男人装 <noreply@nanrenainvren.com>)
就可以正确发出去。
太郁闷了,结果还找错方向了,还以为email服务器出了问题,把james的源码下载下来端详了半天。。。也没看出个一二三。
回头又仔细读了几篇英文文章,操蛋一点的是,这一切太迟了,已经是半夜了,庆幸点的是我终于解决了。
老外有云:
http://www.ruby-forum.com/topic/185075
引用
Francesco Canessa wrote:
> Hi Chris,
>
> the workaround solved the problem, thank you!
>
> Is there another way to display a name with the email address without
> using angle brackets ?
>
> Thanks!
>
> On Jul 31, 2:26�pm, Chris Schumann <rails-mailing-l...@andreas-s.net>
Display? Sure. Do anything you want.
But as of Rails 2.3.3, the from email address will get the angle
brackets added, so it can only contain the address.
Rails 2.3.4 is/was supposed to fix that, and includes tests so it will
be ensured in future versions.
又恰好在另一个老外的文章中,看到一个链接,原文找不到了,链接还留着。
http://github.com/rails/rails/commit/1d57ccbc6f80a506e5c3867976793310e9148f03
被rails 2.3.3整懵了的是下面的代码:
actionmailer/lib/action_mailer/base.rb
- sender = (mail['return-path'] && mail['return-path'].spec) || mail.from
+ sender = (mail['return-path'] && mail['return-path'].spec) || mail['from']
加号那个是2.3.3后变的,减号那个是以前的。
于是,赶紧把actionmailer/lib/action_mailer/base.rb文件揪出,把mail['from'] 成成mail.from,重启服务器,发邮件吧!!!
"男人装"作为“发件人”的邮件终于出现在邮件列表里了。
注:以上男人装是假的,只是好玩。
---------我说JE,你就不能把广告上面打个空白行吗?----------
分享到:
相关推荐
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
下载自官网,rails-2.3.3.zip 实用先收藏下
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
基于java的开发源码-Rails3消息队列系统 Sidekiq.zip 基于java的开发源码-Rails3消息队列系统 Sidekiq.zip 基于java的开发源码-Rails3消息队列系统 Sidekiq.zip 基于java的开发源码-Rails3消息队列系统 Sidekiq.zip ...
Apress.Beginning.Rails.from.Novice.to.Professional.2007.
Embrace the full stack of web development, from styling with Bootstrap, building an interactive user interface with Angular 2, to storing data quickly and reliably in PostgreSQL. With this fully ...
rails.vim提供了常用的一些命令,可以帮助开发,例如:Rgenerate, Rake, Rfind,RTview等,很方便,也很实用。 安装方法: 拷贝 autoload/rails.vim, plugin/rails.vim, 和 doc/rails.txt 到 ~/.vim 目录. ...
Addison.Wesley.Rails.AntiPatterns.Best.Practice.Ruby.on.Rails.Refactoring
Python开发Rails框架——Django框架介绍.pdf Python开发Rails框架——Django框架介绍.pdf Python开发Rails框架——Django框架介绍.pdfPython开发Rails框架——Django框架介绍.pdf
SitePoint[1].Simply.Rails.2.2nd.Edition.May.2008.pdf
Agile.Web.Development.with.Rails.3nd.Edition.Beta
rails linux 安装程序。 资源来源于 http://blog.csdn.net/spanzhang/archive/2009/09/02/4510871.aspx
Rails3的ActiveRecord 查询API.doc
RailsSpace teaches you Ruby on Rails by developing a real-world application: RailsSpace, a social networking website aimed at the Rails community itself. We take you step by step, from the virtually...
twitter-bootstrap-rails, 用于 Rails 5 4.x 资产管道的Twitter Bootstrap 用于 Rails 5和 Rails 4资产管道的 Twitter BootstrapBootstrap 是 Twitter的工具包,旨在开发网络应用程序和站点的kickstart 。...
weixin_rails_middleware, 微信集成 ruby weixin_rails_middleware for integration weixin.
This concise teaches you how to use the power of Docker and Kubernetes to deploy your Rails applications easily and efficiently. Docker and Kubernetes are increasing in popularity every day, but what ...
Ruby.on.Rails.Tutorial,Learn.Web.Development.with.Rails,Third.Edition-中文版 文字版.pdf 个人收集电子书,仅用学习使用,不可用于商业用途,如有版权问题,请联系删除!