rails send mail set from name

Posted by wxianfeng Thu, 17 Sep 2009 17:14:00 GMT

效果

以前 用 google 的 smtp 服务 成功发送了 email.

http://www.blogjava.net/fl1429/archive/2009/05/04/268866.html

由于 google 的 smtp 每天只容许 发送 500 封email,所以必须自己搭建邮件服务器了。。。。邮件服务器用的是 kerio mail server , 搭好之后 enviroment.rb 中 配置

ActionMailer::Base.perform_deliveries = true
 ActionMailer::Base.raise_delivery_errors = true
 ActionMailer::Base.default_charset = "utf-8"
 ActionMailer::Base.default_content_type = "text/html"
 ActionMailer::Base.smtp_settings = {
     :address => "59.314.13.266",
     :port => 25,
     :domain => "www.abc.com",
     :user_name => "webmaster",
     :password => "riskfit654321",
     :authentication => :login
     }

Model里的send 方法

  def send_password(recipient, subject, name,password)
    @subject = subject 
    @recipients = recipient 
    @from = 'webmaster@abc.com'
    @sent_on = Time.now   
    @body["name"] = name 
    @body['password'] = password 
    @headers = {}
  end

可是 发送 email 后 , 邮箱 显示的发件人 始终是 webmaster , 那么 我 想让发件人的名字显示成 测试 , 该如何设置呢,那么把@from 设置成这样 :

@from = '"测试"<webmaster@abc.com>' # 主意是外面是单引号 , 里面 是 双引号 ,而且用户名webmaster 必须和 config里的user_name 一样

ref:

http://www.javaeye.com/topic/126875

This entry was posted on Thu, 17 Sep 2009 17:14:00 GMT and Posted in . You can follow any any response to this entry through the Atom feed. You can leave a comment or a trackback from your own site.

Tags ,


Trackbacks

Use the following link to trackback from your own site:
http://wxianfeng.com/trackbacks?article_id=3

Comments

  1. Avatar
    site about {{count}} years ago:

    Thanks , I have just been looking for ibfo approximately this
    subject for ages and yours is the greateest I’ve discovered till now.

    But, what concerning the bottom line? Are you sure about
    the supply?

  2. Avatar
    devenir riche sur internet about {{count}} years ago:

    I loved as much as you’ll receive carried oout right here.
    The sketch is attractive, your authored subject matter stylish.

    nonetheless, you command get got an shakiness
    over that you wish be delivering the following. unwell unquestionably
    come further formerly again since exactly the same nearly a lot often inside case you shield this hike.

  3. Avatar
    Rencontre adultère about {{count}} years ago:

    I’m gone to inform my little brother, tat he
    should alao visit this webpage on regular basis to take updated from most recent reports.

  4. Avatar
    Rencontre infidele over {{count}} years ago:

    Every weekend i used to pay a vizit this site, for the reason that i want enjoyment,
    as this this site conations really good funny information too.

  5. Avatar
    Rencontre infidele over {{count}} years ago:

    What’s up it’s me, I am also visiting this website
    on a regular basis, this web page is truly fastidious and the users are really sharing fastidious thoughts.

  6. Avatar
    Rencontre infidele over {{count}} years ago:

    What’s uup it’s me, I am also visitibg this website on a regular basis,
    this web page is truly fastidious and the users are really sharing fastidious
    thoughts.

  7. Avatar
    communication non verbale over {{count}} years ago:

    Wow! In the end I got a webpage from where I
    be able to really get valuable information concerning my study and knowledge.

  8. Avatar
    communication non verbale over {{count}} years ago:

    Wow! In the end I got a webpage from where I be able to really
    get valuable information concerning my study and knowledge.

  9. Avatar
    antibuk.ru over {{count}} years ago:

    An impressive share! I’ve just forwarded this onto a co-worker who has
    been doing a little homework on this. And hhe in fsct ordered me lunch simply because I
    found it for him… lol. So let me reword this…. Thanks for the meal!!
    Butt yeah, thanks for spending skme time to talk about this ssue here on your blog.

  10. Avatar
    antibuk.ru over {{count}} years ago:

    An impressive share! I’ve just forwarded this onto a co-worker
    who has been doing a little hommework on this.

    And he in fact ordered me lunch simply because I
    fohnd it for him… lol. So let me reword this…. Thanls for the meal!!
    But yeah,thanks for spending some time to talk about this issue here on your blog.

  11. Appreciate the recommendation. Let mme try it out.

  12. Avatar
    παιδικα παπουτσια over {{count}} years ago:

    Woah! I’m really lovingg the template/themeof thi blog. It’s
    simple, yet effective. A lot of times it’s tough to get that “perfect balance” between uswr friendliness and appearance.
    I must saay that you’ve done a amazing job with this.

    Also, the blog loads very quic for mee on Firefox. Exceptional Blog!

Leave a comment