Skip to content

Instantly share code, notes, and snippets.

@derveloper
Created December 12, 2012 20:40
Show Gist options
  • Save derveloper/4271419 to your computer and use it in GitHub Desktop.
Save derveloper/4271419 to your computer and use it in GitHub Desktop.
wichtelscript
#!/usr/bin/env ruby
# encoding: utf-8
WICHTEL = []
mailtpl = `cat mailtpl.txt`
File.open('wichtel.txt', 'r').each do |f|
WICHTEL << f.strip
end
WICHTEL = WICHTEL.shuffle.shuffle
WICHTEL.each_with_index do |w,i|
pair = [w, i == WICHTEL.size-1 ? WICHTEL[0] : WICHTEL[i+1] ]
sender_mail = pair[0].split(',')[0]
sender_name = pair[0].split(',')[1]
recipient_mail = pair[1].split(',')[0]
recipient_name = pair[1].split(',')[1]
mail = mailtpl.gsub(/USER/, recipient_name)
mail = mail.gsub(/To: .*/,"To: #{sender_mail}")
`echo "#{mail}" > tickets/#{sender_name}.txt`
`ssmtp #{sender_mail} < tickets/#{sender_name}.txt`
`rm tickets/#{sender_name}.txt`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment