Skip to content

Instantly share code, notes, and snippets.

@qichunren
Created January 9, 2010 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qichunren/272770 to your computer and use it in GitHub Desktop.
Save qichunren/272770 to your computer and use it in GitHub Desktop.
# at bottom of environment.rb
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.default_content_type = "text/html"
ActionMailer::Base.smtp_settings = {
:address => "smtp.126.com",
:port => 25,
:domain => "www.zhaoonline.com.com",
:authentication => :login,
:user_name => "boy.365@126.com",
:password => "xxxxxxxx",
}
# in directory app/models
class Notifications < ActionMailer::Base
def test(sent_at, content)
subject 'Notificationsssssssssssssssssss'
recipients 'whyruby@gmail.com'
from 'boy.365@126.com'
sent_on sent_at
body :greeting => content
end
end
# the email body templete in directory app/views
<%= @greeting %>
# sent it!!!
content = IO.readlines("#{Rails.root}/public/ads20091225.htm",'').to_s
Notifications.deliver_test(Time.now, content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment