Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/ruby
- require 'rubygems'
- require 'pp'
- require_gem 'actionmailer'
- ActionMailer::Base.template_root = 'templates'
- ActionMailer::Base.delivery_method = :test
- class TestMailer < ActionMailer::Base
- def test
- #Thread.new do
- @recipients = 'sometest@gmail.com'
- @subject = 'Testing ActionMailer'
- @from = 'admin@rubyonrailsblog.com'
- end
- end
- end
- if $0 == __FILE__
- TestMailer.deliver_test
- ActionMailer::Base.deliveries.each do |mail|
- puts "#{'='*60}"
- puts "Subject: #{mail.subject}"
- puts "From: #{mail.from}"
- puts "To: #{mail.to}"
- puts "#{'-'*60}"
- puts "#{mail.body}"
- end
- end
- ==-======
- require 'rubygems'
- require 'mailfactory'
- def mailer mail
- Thread.new do
- sendmail = IO.popen "sendmail #{mail.to}", 'w+'
- sendmail.puts mail.to_s
- sendmail.close
- end
- end
- mail = MailFactory.new
- mail.to = 'admin@rubyonrailsblog.com'
- mail.from = 'test@rubyonrailsblog.com'
- mail.subject = "[test]"
- mail.text = %{
- Just a test.
- }
- t = []
- 100.times do
- t << mailer(mail)
- end
- t.each{|tt| t.join}
Add Comment
Please, Sign In to add comment