我生产环境的邮件配置是这样的:
config.action_mailer.smtp_settings = {
:address => "smtp.exmail.qq.com",
:port => 25,
:domain => "zhangtianshi.com",
:authentication => :login,
:user_name => "[email protected]",
:password => "tianshi"
}
给用户发送邮件时,看到的发件人别名是 autopost,也就是我邮箱到名称,如何更改这个别名?比如改成“天师“。
#1 楼 @chechaoyang 是直接在 config.action_mailer.smtp_settings 这个配置里面加上 default :from => '天师 [email protected]'吗?
#4 楼 @chechaoyang
我把default :from => "hahah<[email protected]>"
这句话放到了正确位置,邮件发送成功了。
但是我改成default :from => "地图汇<[email protected]>"
,这时候就会出现下面的错误:
550 Invalid User
/home/charles/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/smtp.rb:954:in check_response'
/home/charles/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/smtp.rb:923:in
getok'
/home/charles/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/smtp.rb:838:in mailfrom'
/home/charles/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/smtp.rb:665:in
send_message'
/home/charles/.rvm/gems/ruby-1.9.2-p320/gems/mail-2.4.4/lib/mail/network/delivery_methods/smtp.rb:145:in block in deliver!'
/home/charles/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/smtp.rb:526:in
start'
/home/charles/.rvm/gems/ruby-1.9.2-p320/gems/mail-2.4.4/lib/mail/network/delivery_methods/smtp.rb:144:in deliver!'
/home/charles/.rvm/gems/ruby-1.9.2-p320/gems/mail-2.4.4/lib/mail/message.rb:2034:in
do_delivery'
/home/charles/.rvm/gems/ruby-1.9.2-p320/gems/mail-2.4.4/lib/mail/message.rb:229:in block in deliver'
/home/charles/.rvm/gems/ruby-1.9.2-p320/gems/actionmailer-3.2.0/lib/action_mailer/base.rb:414:in
block in deliver_mail'
/home/charles/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.0/lib/active_support/notifications.rb:123:in block in instrument'
/home/charles/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.0/lib/active_support/notifications/instrumenter.rb:20:in
instrument'
/home/charles/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.0/lib/active_support/notifications.rb:123:in instrument'
/home/charles/.rvm/gems/ruby-1.9.2-p320/gems/actionmailer-3.2.0/lib/action_mailer/base.rb:412:in
deliver_mail'
/home/charles/.rvm/gems/ruby-1.9.2-p320/gems/mail-2.4.4/lib/mail/message.rb:229:in deliver'
/home/charles/.rvm/gems/ruby-1.9.2-p320/gems/resque_mailer-2.1.0/lib/resque_mailer.rb:42:in
perform'
#6 楼 @chechaoyang 可能是这个网站的缺陷吧,我编辑的时候那个尖括号是有的,预览就没有了。 我的程序里是按照您第一次给的方法做的。您再帮忙看看上面的问题吧。