⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 18 - sending mail with rails.rb

📁 O Reilly Ruby Cookbook source code
💻 RB
字号:
./script/generate mailer Notification welcome      exists  app/models/      create  app/views/notification      exists  test/unit/      create  test/fixtures/notification      create  app/models/notification.rb      create  test/unit/notification_test.rb      create  app/views/notification/welcome.rhtml      create  test/fixtures/notification/welcome#---class Notification < ActionMailer::Base  def welcome(user, sent_at=Time.now)    @subject =  'A Friendly Welcome'    @recipients = user.email    @from =  'admin@mysite.com'    @sent_on =    sent_at    @body = {      :user => user,      :sent_on => sent_at    }        attachment 'text/plain' do |a|      a.body = File.read('rules.txt')    end  endend#---<!-- app/views/notification/welcome.rhtml -->Hello, <%= @user.name %>, and thanks for signing up at <%= @sent_on%>. Please print out the attached set of rules and keep them in aprominent place; they help keep our community running smoothly. Besure to pay special attention to sections II.4 ("Assignment ofIntellectual Property Rights") and XIV.21.a ("Dispute ResolutionThrough Ritual Combat").#---Notification.deliver_welcome(user)#---content_type 'text/html'#---Rails::Initializer.run do |config|  config.action_mailer.server_settings = {    :address => 'someserver.com',    :user_name => 'uname',    :password => 'passwd',    :authentication => 'cram_md5'  }end#---

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -