Guest User

Untitled

a guest
Feb 20th, 2018
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #!/usr/local/bin/ruby
  2.  
  3. require 'rubygems'
  4. require 'pp'
  5. require_gem 'actionmailer'
  6. ActionMailer::Base.template_root = 'templates'
  7. ActionMailer::Base.delivery_method = :test
  8. class TestMailer < ActionMailer::Base
  9. def test
  10. #Thread.new do
  11. @recipients = 'sometest@gmail.com'
  12. @subject = 'Testing ActionMailer'
  13. @from = 'admin@rubyonrailsblog.com'
  14. end
  15. end
  16. end
  17. if $0 == __FILE__
  18. TestMailer.deliver_test
  19. ActionMailer::Base.deliveries.each do |mail|
  20. puts "#{'='*60}"
  21. puts "Subject: #{mail.subject}"
  22. puts "From: #{mail.from}"
  23. puts "To: #{mail.to}"
  24. puts "#{'-'*60}"
  25. puts "#{mail.body}"
  26. end
  27. end
  28.  
  29. ==-======
  30.  
  31. require 'rubygems'
  32. require 'mailfactory'
  33.  
  34. def mailer mail
  35. Thread.new do
  36. sendmail = IO.popen "sendmail #{mail.to}", 'w+'
  37. sendmail.puts mail.to_s
  38. sendmail.close
  39. end
  40. end
  41.  
  42. mail = MailFactory.new
  43. mail.to = 'admin@rubyonrailsblog.com'
  44. mail.from = 'test@rubyonrailsblog.com'
  45. mail.subject = "[test]"
  46. mail.text = %{
  47. Just a test.
  48. }
  49.  
  50. t = []
  51.  
  52. 100.times do
  53. t << mailer(mail)
  54. end
  55.  
  56. t.each{|tt| t.join}
Add Comment
Please, Sign In to add comment