Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "eventmachine"
- EM.run do
- 1.upto 100 do |i| #this could be database records
- email = EM::Protocols::SmtpClient.send(
- :auth => {:type => :plain, :username => "username@domain.com", :password => ""},
- :domain => "domain.com",
- :host => "smtp.gmail.com",
- :port => 587,
- :starttls => true,
- :from => "sender@example.com",
- :to => ["username@domain.com"],
- :header => { "Subject" => "This is a subject line (#{i})" },
- :body => "#{i}> This is the body of the email")
- email.callback do
- puts "Email sent! for #{i}"
- end
- email.errback do |e|
- puts "Email failed! #{e.inspect}"
- end
- end
- end
Add Comment
Please, Sign In to add comment