How does Actionmailer work?

社会主义新天地 提交于 2019-12-11 07:44:30

问题


If I need send some letter to 2 people, how can I do this? I found docs in web, but I don't understand them, can you show me and explain me using simple language?


回答1:


def send_mail_persons(user)
  @user = user
  mail :to => @user.email, :subject => "Amusement.", :from => MAIL_ADDRESS
end

Here i have called the method send_mail_persons and passed the recipients info as a parameter.Also there is a simple way..

def send_mail_persons
  mail :to => MAILING_ADDRESS, :subject => "Amusement.", :from => MAIL_ADDRESS
end

and define both MAILING_ADDRESS and MAIL_ADDRESS in the constants.

Thanx




回答2:


Best you can find is Ryan's Railscast:

http://railscasts.com/episodes/206-action-mailer-in-rails-3

Also good guide is here:

http://guides.rubyonrails.org/action_mailer_basics.html

Actually you can read there not just about ActionMailer but about whole Rails kitchen.



来源:https://stackoverflow.com/questions/5485348/how-does-actionmailer-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!