在Rails中配置多个邮件服务器发邮件

阅读更多

在Rails中配置多个邮件服务器发邮件(转)
http://blog.lxneng.com/?p=174

在项目中不同的mailer用不同的邮件地址发送邮件
新建一个配置文件(#{RAILS_ROOT}/config/action_mailer.yml)
noreply:
domain: lxneng.com
user_name: [email protected]
password: noreply
address: smtp.gmail.com
port: 587
authentication: :plain
bug:
domain: lxneng.com
user_name: [email protected]
password: service
address: smtp.gmail.com
port: 587
authentication: :plain
然后在Mailer中加载设置
class UserMailer  options["address"],
:port=> options["port"],
:domain=> options["domain"],
:authentication=> options["authentication"],
:user_name=> options["user_name"],
:password=> options["password"]
}
end
#-----------------deliver method-----------------------------
def welcome_email(recipient, sent_at = Time.now)
load_settings
subject 'Thank you for visiting'
recipients recipient
from 'lxneng '
sent_on sent_at
end
end




你可能感兴趣的:(mailer)