Skip to content

Instantly share code, notes, and snippets.

@tomasv
Created July 13, 2011 18:21
Show Gist options
  • Save tomasv/1080938 to your computer and use it in GitHub Desktop.
Save tomasv/1080938 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'mail'
Mail.defaults do
delivery_method :smtp, { :address => "smtp.gmail.com",
:port => 587,
:domain => 'varneckas.lt',
:user_name => 'tomas@varneckas.lt',
:password => '',
:authentication => 'plain',
:enable_starttls_auto => true }
end
numbers = File.read("numbers.txt").split("\n")
body_text = File.read("body.txt")
attachment = File.open("attachment").path
size = numbers.size
numbers.each_with_index do |number, index|
Mail.deliver do
from "tomas@varneckas.lt"
to "t.varneckas@gmail.com"
subject number
body body_text
add_file attachment
end
puts "#{number} sent. #{index.succ}/#{size}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment