Rails一个班轮邮件发送?

时间:2012-03-02 15:33:32

标签: ruby-on-rails-3 actionmailer

如何在不创建邮件程序类的情况下在一行中发送电子邮件?

我需要设置所有参数,包括:from(与smtp用户不同)

到目前为止,我得到了这个:

# ok not exactly a one liner, but it doesn't matter
ActionMailer::Base.mail(:from => 'admin@mysite.me', :to => 'someone@gmail.com', :subject => 'subject bla') do
  'content bla'
end.deliver

内容无效,我收到一封空白的电子邮件

1 个答案:

答案 0 :(得分:21)

ActionMailer::Base.mail(from: 'from@domain.com', to: 'to@domain.com', subject: "Welcome to My Awesome Site", body: 'I am the email body.').deliver

哦,我们有一个班轮!