bin/rumble in rumble-0.3.7 vs bin/rumble in rumble-0.4.0
- old
+ new
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
-# Copyright (c) 2018 Yegor Bugayenko
+# Copyright (c) 2018-2019 Yegor Bugayenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -52,10 +52,13 @@
end
o.bool '--dry', 'Dry run, no emails will be delivered'
o.string '--from',
'Full SMTP From field, e.g. "John Doe <jd@example.com>"',
required: true
+ o.string '--method',
+ 'How to deliver them: "smtp" or "sendmail" (default: sendmail)',
+ default: 'sendmail'
o.string '--host', 'SMTP host name', required: true
o.string '--port', 'SMTP port number (25 by default)', default: 25
o.string '--user', 'SMTP user name', required: true
o.string '--password', 'SMTP password', required: true
o.string '--subject', 'Email subject', required: true
@@ -67,23 +70,30 @@
o.string '--col-first', 'First name columm (0 by default)', default: 0
o.string '--col-last', 'Last name columm (1 by default)', default: 1
o.string '--col-email', 'Email columm (2 by default)', default: 2
end
rescue Slop::Error => ex
- raise StandardError, "#{ex.message}, try --help"
+ raise "#{ex.message}, try --help"
end
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
Mail.defaults do
- delivery_method :smtp, {
- :address => opts[:host],
- :port => opts[:port],
- :user_name => opts[:user],
- :password => opts[:password],
- :enable_starttls_auto => true
- }
+ case opts[:method].downcase.strip
+ when 'sendmail'
+ delivery_method :sendmail
+ when 'smtp'
+ delivery_method :smtp, {
+ :address => opts[:host],
+ :port => opts[:port],
+ :user_name => opts[:user],
+ :password => opts[:password],
+ :enable_starttls_auto => true
+ }
+ else
+ raise "Delivery method #{opts[:method]} is not supported"
+ end
end
Rumble::CLI.new(opts).send
rescue StandardError => ex