mailcatcher 0.1.3 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/mailcatcher +0 -4
  2. data/lib/mail_catcher.rb +26 -14
  3. metadata +12 -25
data/bin/mailcatcher CHANGED
@@ -1,12 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'bundler'
4
- Bundler.setup
5
-
6
3
  $: << File.expand_path(File.join(File.dirname(__FILE__), '../lib'))
7
4
 
8
5
  require 'mail_catcher'
9
-
10
6
  require 'optparse'
11
7
 
12
8
  options = {}
data/lib/mail_catcher.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require 'eventmachine'
2
3
  require 'json'
3
4
  require 'ostruct'
@@ -87,21 +88,32 @@ module MailCatcher
87
88
  end
88
89
 
89
90
  def receive_message
90
- mail = Mail.new(current_message.source)
91
- result = insert_message.execute(current_message.sender, current_message.recipients.inspect, mail.subject, current_message.source, current_message.source.length)
92
- mail_id = MailCatcher.db.last_insert_row_id
93
- if mail.multipart?
94
- mail.all_parts.each do |part|
95
- body = part.body.to_s
96
- insert_part.execute(mail_id, part.cid, part.mime_type, part.attachment? ? 1 : 0, part.filename, body, body.length)
91
+ MailCatcher.db.transaction do
92
+ mail = Mail.new(current_message.source)
93
+ result = insert_message.execute(current_message.sender, current_message.recipients.inspect, mail.subject, current_message.source, current_message.source.length)
94
+ mail_id = MailCatcher.db.last_insert_row_id
95
+ if mail.multipart?
96
+ mail.all_parts.each do |part|
97
+ body = part.body.to_s
98
+ insert_part.execute(mail_id, part.cid, part.mime_type, part.attachment? ? 1 : 0, part.filename, body, body.length)
99
+ end
100
+ else
101
+ body = mail.body.to_s
102
+ insert_part.execute(mail_id, nil, mail.mime_type, 0, mail.filename, body, body.length)
97
103
  end
98
- else
99
- body = mail.body.to_s
100
- insert_part.execute(mail_id, nil, mail.mime_type, 0, mail.filename, body, body.length)
104
+ puts "==> SMTP: Received message '#{mail.subject}' from '#{current_message.sender}'"
105
+ true
106
+ end
107
+ rescue
108
+ puts "*** Error receiving message: #{current_message.inspect}"
109
+ puts " Exception: #{$!}"
110
+ puts " Backtrace:"
111
+ $!.backtrace.each do |line|
112
+ puts " #{line}"
101
113
  end
102
- puts "==> SMTP: Received message '#{mail.subject}' from '#{current_message.sender}'"
114
+ puts " Please submit this as an issue at http://github.com/sj26/mailcatcher/issues"
115
+ ensure
103
116
  @current_message = nil
104
- true
105
117
  end
106
118
  end
107
119
 
@@ -209,8 +221,8 @@ module MailCatcher
209
221
  puts "==> http://#{options[:http_ip]}:#{options[:http_port]}"
210
222
 
211
223
  Thin::Logging.silent = true
212
- EM::run do
213
- EM::start_server options[:smtp_ip], options[:smtp_port], SmtpServer
224
+ EM.run do
225
+ EM.start_server options[:smtp_ip], options[:smtp_port], SmtpServer
214
226
  Thin::Server.start WebApp, options[:http_ip], options[:http_port]
215
227
  end
216
228
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 3
9
- version: 0.1.3
8
+ - 6
9
+ version: 0.1.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Samuel Cochran
@@ -14,11 +14,11 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-25 00:00:00 +08:00
17
+ date: 2010-10-26 00:00:00 +08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: bundler
21
+ name: eventmachine
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
@@ -31,7 +31,7 @@ dependencies:
31
31
  type: :runtime
32
32
  version_requirements: *id001
33
33
  - !ruby/object:Gem::Dependency
34
- name: eventmachine
34
+ name: haml
35
35
  prerelease: false
36
36
  requirement: &id002 !ruby/object:Gem::Requirement
37
37
  none: false
@@ -44,7 +44,7 @@ dependencies:
44
44
  type: :runtime
45
45
  version_requirements: *id002
46
46
  - !ruby/object:Gem::Dependency
47
- name: haml
47
+ name: json
48
48
  prerelease: false
49
49
  requirement: &id003 !ruby/object:Gem::Requirement
50
50
  none: false
@@ -57,7 +57,7 @@ dependencies:
57
57
  type: :runtime
58
58
  version_requirements: *id003
59
59
  - !ruby/object:Gem::Dependency
60
- name: json
60
+ name: mail
61
61
  prerelease: false
62
62
  requirement: &id004 !ruby/object:Gem::Requirement
63
63
  none: false
@@ -70,7 +70,7 @@ dependencies:
70
70
  type: :runtime
71
71
  version_requirements: *id004
72
72
  - !ruby/object:Gem::Dependency
73
- name: mail
73
+ name: thin
74
74
  prerelease: false
75
75
  requirement: &id005 !ruby/object:Gem::Requirement
76
76
  none: false
@@ -83,7 +83,7 @@ dependencies:
83
83
  type: :runtime
84
84
  version_requirements: *id005
85
85
  - !ruby/object:Gem::Dependency
86
- name: thin
86
+ name: sqlite3-ruby
87
87
  prerelease: false
88
88
  requirement: &id006 !ruby/object:Gem::Requirement
89
89
  none: false
@@ -96,7 +96,7 @@ dependencies:
96
96
  type: :runtime
97
97
  version_requirements: *id006
98
98
  - !ruby/object:Gem::Dependency
99
- name: sqlite3-ruby
99
+ name: sinatra
100
100
  prerelease: false
101
101
  requirement: &id007 !ruby/object:Gem::Requirement
102
102
  none: false
@@ -109,7 +109,7 @@ dependencies:
109
109
  type: :runtime
110
110
  version_requirements: *id007
111
111
  - !ruby/object:Gem::Dependency
112
- name: sinatra
112
+ name: sunshowers
113
113
  prerelease: false
114
114
  requirement: &id008 !ruby/object:Gem::Requirement
115
115
  none: false
@@ -122,7 +122,7 @@ dependencies:
122
122
  type: :runtime
123
123
  version_requirements: *id008
124
124
  - !ruby/object:Gem::Dependency
125
- name: sunshowers
125
+ name: i18n
126
126
  prerelease: false
127
127
  requirement: &id009 !ruby/object:Gem::Requirement
128
128
  none: false
@@ -134,19 +134,6 @@ dependencies:
134
134
  version: "0"
135
135
  type: :runtime
136
136
  version_requirements: *id009
137
- - !ruby/object:Gem::Dependency
138
- name: i18n
139
- prerelease: false
140
- requirement: &id010 !ruby/object:Gem::Requirement
141
- none: false
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- segments:
146
- - 0
147
- version: "0"
148
- type: :runtime
149
- version_requirements: *id010
150
137
  description: " MailCatcher runs a super simple SMTP server which catches any\n message sent to it to display in a web interface. Run\n mailcatcher, set your favourite app to deliver to\n smtp://127.0.0.1:1025 instead of your default SMTP server,\n then check out http://127.0.0.1:1080 to see the mail.\n"
151
138
  email: sj26@sj26.com
152
139
  executables: