From e76d3677555def4968e609beffc468300f5205ed Mon Sep 17 00:00:00 2001 From: Samuel Cochran Date: Sat, 17 Jan 2015 15:21:13 +1100 Subject: [PATCH] Bring `catchmail` closer to `sendmail` Sendmail's conventional interface is `sendmail [options] [recipient ...]` Fixes #188 --- bin/catchmail | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/catchmail b/bin/catchmail index 40ef230..28c6ec6 100755 --- a/bin/catchmail +++ b/bin/catchmail @@ -13,7 +13,7 @@ options = {:smtp_ip => '127.0.0.1', :smtp_port => 1025} OptionParser.new do |parser| parser.banner = <<-BANNER.gsub /^ +/, "" - Usage: catchmail [options] + Usage: catchmail [options] [recipient ...] sendmail-like interface to forward mail to MailCatcher. BANNER @@ -56,6 +56,16 @@ Mail.defaults do :port => options[:smtp_port] end -message = Mail.new ARGF.read +message = Mail.new($stdin.read) + message.return_path = options[:from] if options[:from] + +ARGV.each do |recipient| + if message.to.nil? + message.to = recipient + else + message.to << recipient + end +end + message.deliver