Guest User

Untitled

a guest
Jun 2nd, 2018
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. require "eventmachine"
  2.  
  3. EM.run do
  4. 1.upto 100 do |i| #this could be database records
  5. email = EM::Protocols::SmtpClient.send(
  6. :auth => {:type => :plain, :username => "username@domain.com", :password => ""},
  7. :domain => "domain.com",
  8. :host => "smtp.gmail.com",
  9. :port => 587,
  10. :starttls => true,
  11. :from => "sender@example.com",
  12. :to => ["username@domain.com"],
  13. :header => { "Subject" => "This is a subject line (#{i})" },
  14. :body => "#{i}> This is the body of the email")
  15.  
  16. email.callback do
  17. puts "Email sent! for #{i}"
  18. end
  19.  
  20. email.errback do |e|
  21. puts "Email failed! #{e.inspect}"
  22. end
  23. end
  24. end
Add Comment
Please, Sign In to add comment