vmail 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -245,6 +245,13 @@ split window, etc.) Resume editing. Send by typing `,vs`.
245
245
 
246
246
  At any point, you can quit the composition window by typing `q` in normal mode.
247
247
 
248
+ You can also use `vmailsend` from the command line to send a message that
249
+ you've compmosed with correct headers and saved to a file, like so.
250
+
251
+ vmailsend < my_message.txt
252
+
253
+ vmailsend uses your `.vmailrc` configuration.
254
+
248
255
  ## Attachments
249
256
 
250
257
  The current version of vmail can handle attachments to a certain extent.
@@ -85,10 +85,12 @@ module Vmail
85
85
  end
86
86
 
87
87
  def prime_connection
88
+ return if @ids.nil? || @ids.empty?
88
89
  reconnect_if_necessary(4) do
89
90
  # this is just to prime the IMAP connection
90
91
  # It's necessary for some reason before update and deliver.
91
92
  log "priming connection for delivering"
93
+
92
94
  res = @imap.fetch(@ids[-1], ["ENVELOPE"])
93
95
  if res.nil?
94
96
  # just go ahead, just log
@@ -572,8 +574,16 @@ EOF
572
574
  prime_connection
573
575
  mail = new_mail_from_input(text)
574
576
  mail.delivery_method(*smtp_settings)
575
- log mail.deliver!
576
- "message '#{mail.subject}' sent"
577
+ res = mail.deliver!
578
+ log res.inspect
579
+ log "\n"
580
+ msg = if res.is_a?(Mail::Message)
581
+ "message '#{mail.subject}' sent"
582
+ else
583
+ "failed to deliver message '#{mail.subject}'"
584
+ end
585
+ log msg
586
+ msg
577
587
  end
578
588
 
579
589
  def new_mail_from_input(text)
@@ -585,8 +595,7 @@ EOF
585
595
  key, value = *line.split(/:\s*/, 2)
586
596
  headers[key] = value
587
597
  end
588
- log "headers: #{headers.inspect}"
589
- log "delivering: #{headers.inspect}"
598
+ log "delivering message with headers: #{headers.to_yaml}"
590
599
  mail.from = headers['from'] || @username
591
600
  mail.to = headers['to'] #.split(/,\s+/)
592
601
  mail.cc = headers['cc'] #&& headers['cc'].split(/,\s+/)
@@ -0,0 +1,54 @@
1
+ require 'vmail/options'
2
+
3
+ module Vmail
4
+ class SendOptions < Vmail::Options
5
+
6
+ def parse(argv)
7
+ OptionParser.new do |opts|
8
+ opts.banner = "Usage: vmailsend"
9
+ opts.separator ""
10
+ opts.separator "Specific options:"
11
+ opts.on("-c", "--config path", String, "Path to config file") do |config_file|
12
+ @config_file = config_file
13
+ end
14
+ opts.on("-v", "--version", "Show version (identical to vmail version)") do
15
+ require 'vmail/version'
16
+ puts "vmail #{Vmail::VERSION}\nCopyright 2010 Daniel Choi under the MIT license"
17
+ exit
18
+ end
19
+ opts.on("-h", "--help", "Show this message") do
20
+ puts opts
21
+ exit
22
+ end
23
+ opts.separator ""
24
+ opts.separator INSTRUCTIONS
25
+
26
+ begin
27
+ opts.parse!(argv)
28
+ if @config_file && File.exists?(@config_file)
29
+ puts "Using config file #{@config_file}"
30
+ else
31
+ puts <<EOF
32
+
33
+ Missing config file!
34
+
35
+ #{INSTRUCTIONS}
36
+ EOF
37
+ exit(1)
38
+ end
39
+
40
+ @config = YAML::load(File.read(@config_file))
41
+ if @config['password'].nil?
42
+ @config['password'] = ask("Enter gmail password (won't be visible & won't be persisted):") {|q| q.echo = false}
43
+ end
44
+
45
+ rescue OptionParser::ParseError => e
46
+ STDERR.puts e.message, "\n", opts
47
+ end
48
+
49
+ end
50
+ end
51
+ end
52
+
53
+ end
54
+
@@ -1,11 +1,12 @@
1
+ require 'vmail/send_options'
1
2
  require 'vmail/imap_client'
2
3
 
3
4
  module Vmail
4
- class Sender
5
+ module Sender
5
6
  extend self
6
7
 
7
8
  def send
8
- opts = Vmail::Options.new(ARGV)
9
+ opts = Vmail::SendOptions.new(ARGV)
9
10
  config = opts.config.merge 'logile' => STDERR
10
11
  imap_client = Vmail::ImapClient.new config
11
12
  imap_client.deliver STDIN.read
@@ -1,3 +1,3 @@
1
1
  module Vmail
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 6
8
- - 0
9
- version: 0.6.0
8
+ - 1
9
+ version: 0.6.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Choi
@@ -74,6 +74,7 @@ files:
74
74
  - lib/vmail/message_formatter.rb
75
75
  - lib/vmail/options.rb
76
76
  - lib/vmail/reply_template.rb
77
+ - lib/vmail/send_options.rb
77
78
  - lib/vmail/sender.rb
78
79
  - lib/vmail/string_ext.rb
79
80
  - lib/vmail/version.rb