bin/remail in reaction_mailer-0.0.1 vs bin/remail in reaction_mailer-0.0.2

- old
+ new

@@ -7,11 +7,13 @@ require 'pp' options = Hash.new(false) OptionParser.new do|opts| - opts.banner = "Usage: remail [options] file1 file2 ... \n\n" + opts.banner = "Usage: remail [options] file1 file2 ... \n" + + " remail [options] directory\n" + + " remail [options] -p\n\n" opts.on( '-u', '--username USERNAME', "Gmail Username" ) do|u| options[:user] = u end @@ -34,42 +36,42 @@ end.parse! options[:user] = ask("Enter your gmail username: ") unless options[:user] options[:pass] = ask("Enter your gmail password: ") { |q| q.echo = "*" } unless options[:pass] -if /@(.*$)/.match(options[:user]) - domain = /@(.*$)/.match(options[:user])[1] -else - domain = 'gmail.com' -end +domain = options[:user][/@(.*$)/] || 'gmail.com' -mail_settings = { - :address => "smtp.gmail.com", - :port => 587, - :domain => domain, - :user_name => options[:user], - :password => options[:pass], - :authentication => 'plain', - :enable_starttls_auto => true -} - Mail.defaults do - delivery_method :smtp, mail_settings + delivery_method :smtp, :address => "smtp.gmail.com", + :port => 587, + :domain => domain, + :user_name => options[:user], + :password => options[:pass], + :authentication => 'plain', + :enable_starttls_auto => true + retriever_method :pop3, :address => "localhost", :port => 2220, :user_name => 'reaction', :password => 'canttouchthis' end -unless options[:pop] - mail = [] - ARGV.each do |f| +mail = [] +ARGV.each do |f| + if File.directory?(f) + Dir[f+"*"].each do |m| + if File.file? m + mail << Mail.read(m) + end + end + elsif File.file? f mail << Mail.read(f) end -else - mail = Mail.all +end +if options[:pop] + mail << Mail.all end mail.each do |mail| mail.message_id = nil mail.cc = nil