mailtrap 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/History.txt +5 -0
- data/Manifest.txt +6 -0
- data/README.txt +58 -0
- data/Rakefile +20 -0
- data/bin/mailtrap +28 -0
- data/lib/mailtrap.rb +121 -0
- data/test/test_mailtrap.rb +0 -0
- metadata +102 -0
- metadata.gz.sig +0 -0
data.tar.gz.sig
ADDED
Binary file
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
mailtrap
|
2
|
+
by Matt Mower <self@mattmower.com>
|
3
|
+
http://matt.blogs.it/
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Mailtrap is a mock SMTP server for use in Rails development. Mailtrap waits for
|
8
|
+
a client to connect and talks just enough SMTP for ActionMailer to send its message
|
9
|
+
which Mailtrap will write into a file for you to inspect. Mailtrap makes no
|
10
|
+
attempt to actually deliver anything (hence the name Mail*trap*).
|
11
|
+
|
12
|
+
You can configure the hostname (default: localhost) and port (default: 1025)
|
13
|
+
for the server and also where the messages get written (default: /tmp). Messages
|
14
|
+
will get written to files named smtp0001.msg, smtp0002.msg, and so on.
|
15
|
+
|
16
|
+
== FEATURES/PROBLEMS:
|
17
|
+
|
18
|
+
* Test with ActionMailer's SMTP delivery method
|
19
|
+
* Very, very, dumb ... might not work with an arbitrary Mail client
|
20
|
+
|
21
|
+
== SYNOPSIS:
|
22
|
+
|
23
|
+
mailtrap --host localhost --port 8025 --once
|
24
|
+
|
25
|
+
== REQUIREMENTS:
|
26
|
+
|
27
|
+
* Rubygems
|
28
|
+
* Daemons rubygem
|
29
|
+
* Trollop rubygem
|
30
|
+
|
31
|
+
== INSTALL:
|
32
|
+
|
33
|
+
* sudo gem install -y mailtrap
|
34
|
+
|
35
|
+
== LICENSE:
|
36
|
+
|
37
|
+
(The MIT License)
|
38
|
+
|
39
|
+
Copyright (c) 2007 Matt Mower, Software Heretics
|
40
|
+
|
41
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
42
|
+
a copy of this software and associated documentation files (the
|
43
|
+
'Software'), to deal in the Software without restriction, including
|
44
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
45
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
46
|
+
permit persons to whom the Software is furnished to do so, subject to
|
47
|
+
the following conditions:
|
48
|
+
|
49
|
+
The above copyright notice and this permission notice shall be
|
50
|
+
included in all copies or substantial portions of the Software.
|
51
|
+
|
52
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
53
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
54
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
55
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
56
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
57
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
58
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require './lib/mailtrap.rb'
|
6
|
+
|
7
|
+
Hoe.new('mailtrap', Mailtrap::VERSION) do |p|
|
8
|
+
p.rubyforge_name = 'rubymatt'
|
9
|
+
p.author = 'Matt Mower'
|
10
|
+
p.email = 'self@mattmower.com'
|
11
|
+
p.summary = 'Mailtrap is a mock SMTP server for use in Rails development'
|
12
|
+
p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
|
13
|
+
p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
|
14
|
+
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
15
|
+
p.remote_rdoc_dir = 'mailtrap'
|
16
|
+
p.extra_deps << ['daemons','>= 1.0.8']
|
17
|
+
p.extra_deps << ['trollop','>= 1.7']
|
18
|
+
end
|
19
|
+
|
20
|
+
# vim: syntax=Ruby
|
data/bin/mailtrap
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Run the mailtrap server
|
4
|
+
#
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'daemons'
|
8
|
+
require 'mailtrap'
|
9
|
+
|
10
|
+
opts = Trollop::options do
|
11
|
+
opt :host, "The host SMTP clients will connect to", :default => 'localhost'
|
12
|
+
opt :port, "The port SMTP clients will connect to", :default => 2525
|
13
|
+
opt :once, "Whether to terminate after serving the first client", :default => false
|
14
|
+
opt :msgdir, "Where messages get stored", :default => "/var/tmp"
|
15
|
+
end
|
16
|
+
|
17
|
+
options = {
|
18
|
+
:dir_mode => :normal,
|
19
|
+
:dir => '/var/tmp',
|
20
|
+
:multiple => true,
|
21
|
+
:mode => :exec,
|
22
|
+
:backtrace => true,
|
23
|
+
:log_output => true
|
24
|
+
}
|
25
|
+
|
26
|
+
Daemons.run_proc( 'mailtrap', options ) do
|
27
|
+
Mailtrap.new( opts[:host], opts[:port], opts[:once], opts[:msgdir] )
|
28
|
+
end
|
data/lib/mailtrap.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
|
2
|
+
require 'rubygems'
|
3
|
+
require 'daemons'
|
4
|
+
require 'socket'
|
5
|
+
require 'trollop'
|
6
|
+
|
7
|
+
class Mailtrap
|
8
|
+
VERSION = '0.1.0'
|
9
|
+
|
10
|
+
def initialize( host, port, once, msgdir )
|
11
|
+
@host = host
|
12
|
+
@port = port
|
13
|
+
@once = once
|
14
|
+
@msgdir = msgdir
|
15
|
+
|
16
|
+
puts "Mailtrap starting at #{@host}:#{port} and writing to #{@msgdir}"
|
17
|
+
service = TCPServer.new( @host, @port )
|
18
|
+
accept( service )
|
19
|
+
end
|
20
|
+
|
21
|
+
def accept( service )
|
22
|
+
while session = service.accept
|
23
|
+
|
24
|
+
class << session
|
25
|
+
def get_line
|
26
|
+
line = gets
|
27
|
+
line.chomp! unless line.nil?
|
28
|
+
line
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
begin
|
33
|
+
serve( session )
|
34
|
+
rescue Exception => e
|
35
|
+
puts "Erk! #{e.message}"
|
36
|
+
end
|
37
|
+
|
38
|
+
break if @once
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def write( from, to_list, message )
|
43
|
+
|
44
|
+
from.gsub!( /MAIL FROM:\s*/, "" )
|
45
|
+
to_list = to_list.map { |to| to.gsub( /RCPT TO:\s*/, "" ) }
|
46
|
+
|
47
|
+
n = 1
|
48
|
+
Dir.chdir( @msgdir ) do
|
49
|
+
files = Dir.glob( "smtp*.msg" )
|
50
|
+
if files.length > 0
|
51
|
+
n = 1 + Integer( files.last.gsub( /smtp(\d+)\.msg/, '\1' ) )
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
File.open( File.join( @msgdir, "smtp%04d.msg" % n ), "w" ) do |file|
|
56
|
+
file.puts "FROM: #{from}"
|
57
|
+
to_list.each do |to|
|
58
|
+
file.puts "TO: #{to}"
|
59
|
+
end
|
60
|
+
file.puts "----"
|
61
|
+
file.puts message
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
def serve( connection )
|
67
|
+
connection.puts( "220 #{@host} MailTrap ready ESTMP" )
|
68
|
+
helo = connection.get_line # whoever they are
|
69
|
+
puts "Helo: #{helo}"
|
70
|
+
|
71
|
+
if helo =~ /^EHLO\s+/
|
72
|
+
puts "Seen an EHLO"
|
73
|
+
connection.puts "250-#{@host} offers just ONE extension my pretty"
|
74
|
+
connection.puts "250 HELP"
|
75
|
+
end
|
76
|
+
|
77
|
+
from = connection.get_line
|
78
|
+
connection.puts( "250 OK" )
|
79
|
+
puts "From: #{from}"
|
80
|
+
|
81
|
+
to_list = []
|
82
|
+
|
83
|
+
loop do
|
84
|
+
to = connection.get_line
|
85
|
+
break if to.nil?
|
86
|
+
|
87
|
+
if to =~ /^DATA/
|
88
|
+
connection.puts( "354 Start your message" )
|
89
|
+
break
|
90
|
+
else
|
91
|
+
puts "To: #{to}"
|
92
|
+
to_list << to
|
93
|
+
connection.puts( "250 OK" )
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
puts "We know who we're sending to."
|
98
|
+
|
99
|
+
lines = []
|
100
|
+
|
101
|
+
loop do
|
102
|
+
line = connection.get_line
|
103
|
+
break if line.nil? || line == "."
|
104
|
+
lines << line
|
105
|
+
puts "+ #{line}"
|
106
|
+
end
|
107
|
+
|
108
|
+
puts "Message read"
|
109
|
+
connection.puts( "250 OK" )
|
110
|
+
|
111
|
+
connection.gets # Quit
|
112
|
+
connection.puts "221 Seeya"
|
113
|
+
|
114
|
+
connection.close
|
115
|
+
puts "And we're done with that bozo!"
|
116
|
+
|
117
|
+
write( from, to_list, lines.join( "\n" ) )
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.4
|
3
|
+
specification_version: 1
|
4
|
+
name: mailtrap
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.1.0
|
7
|
+
date: 2007-10-04 00:00:00 +01:00
|
8
|
+
summary: Mailtrap is a mock SMTP server for use in Rails development
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: self@mattmower.com
|
12
|
+
homepage: " by Matt Mower <self@mattmower.com>"
|
13
|
+
rubyforge_project: rubymatt
|
14
|
+
description: "Mailtrap is a mock SMTP server for use in Rails development. Mailtrap waits for a client to connect and talks just enough SMTP for ActionMailer to send its message which Mailtrap will write into a file for you to inspect. Mailtrap makes no attempt to actually deliver anything (hence the name Mail*trap*). You can configure the hostname (default: localhost) and port (default: 1025) for the server and also where the messages get written (default: /tmp). Messages will get written to files named smtp0001.msg, smtp0002.msg, and so on. == FEATURES/PROBLEMS: * Test with ActionMailer's SMTP delivery method * Very, very, dumb ... might not work with an arbitrary Mail client == SYNOPSIS:"
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
- |
|
29
|
+
-----BEGIN CERTIFICATE-----
|
30
|
+
MIIDMjCCAhqgAwIBAgIBADANBgkqhkiG9w0BAQUFADA/MQ0wCwYDVQQDDARzZWxm
|
31
|
+
MRkwFwYKCZImiZPyLGQBGRYJbWF0dG1vd2VyMRMwEQYKCZImiZPyLGQBGRYDY29t
|
32
|
+
MB4XDTA3MTAwMzIzMjkwN1oXDTA4MTAwMjIzMjkwN1owPzENMAsGA1UEAwwEc2Vs
|
33
|
+
ZjEZMBcGCgmSJomT8ixkARkWCW1hdHRtb3dlcjETMBEGCgmSJomT8ixkARkWA2Nv
|
34
|
+
bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMVQejbmmtJD6FfTwc9+
|
35
|
+
QsWEqNFgNL8+tbrpxUuT8J2j0O0Pvkhw3wGT3tzMdXlnaz+OwUz8qU6HGwDAiK/3
|
36
|
+
zWAGuBRApkIAooTryRWLYmkZfnZidG8A2msmRwQd84Rkzn6Vgad+46o6jQfJSgy1
|
37
|
+
pDsZVfsRcUZ0dWetp+ll7Lq/4HyecdNgRfmrQh6pmKwIUmh5cj91iBX3NEqx5TN6
|
38
|
+
AKkYIOBMuOnBMNrXvApH10ruvus1d/PiJIjAavvbgSih+vyB8NTXTF4kOhKXnF0w
|
39
|
+
Zx3CF5asJejopRGNUcY9Vmjr7WiRHhUnFjc8hs385MlQNKEdAirVwIIgWfkQwJO+
|
40
|
+
GQ0CAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFL99
|
41
|
+
Fuw4VZwExQog/QSr8zIFfj1WMA0GCSqGSIb3DQEBBQUAA4IBAQATHmiqgSFKeJQM
|
42
|
+
QZjefTiRH6q1TgnJEt0/ylb9gNUCBpIFC1QOtuf68NAt90n6q1CZ51W3EreOPmi2
|
43
|
+
k2UxzfnPH6av2HQxmC1Xwv+X/eKF65shy/D75XWeCKLwynlXbA0cSjkV8/jSDB9I
|
44
|
+
pPXX1PjTNmzS2oNGSBroG567Uod41eAjlFA2FQTSWu/lDaYvLBjupGzz59/lZfkl
|
45
|
+
oCvK+OORDtfJ/a8CdYuD7PltGIEGV9srqdsEsmcrXGHaZt+jGRLYi60h5ZEd7lOm
|
46
|
+
1WEvMXOXF3ofp87Yw1MSpG7yQyr0i5DW6VM3v6AP0ABxoM4p80JDHhwAmKWRWWQk
|
47
|
+
yMQ/kUco
|
48
|
+
-----END CERTIFICATE-----
|
49
|
+
|
50
|
+
post_install_message:
|
51
|
+
authors:
|
52
|
+
- Matt Mower
|
53
|
+
files:
|
54
|
+
- History.txt
|
55
|
+
- Manifest.txt
|
56
|
+
- README.txt
|
57
|
+
- Rakefile
|
58
|
+
- bin/mailtrap
|
59
|
+
- lib/mailtrap.rb
|
60
|
+
test_files:
|
61
|
+
- test/test_mailtrap.rb
|
62
|
+
rdoc_options:
|
63
|
+
- --main
|
64
|
+
- README.txt
|
65
|
+
extra_rdoc_files:
|
66
|
+
- History.txt
|
67
|
+
- Manifest.txt
|
68
|
+
- README.txt
|
69
|
+
executables:
|
70
|
+
- mailtrap
|
71
|
+
extensions: []
|
72
|
+
|
73
|
+
requirements: []
|
74
|
+
|
75
|
+
dependencies:
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: daemons
|
78
|
+
version_requirement:
|
79
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 1.0.8
|
84
|
+
version:
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: trollop
|
87
|
+
version_requirement:
|
88
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: "1.7"
|
93
|
+
version:
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: hoe
|
96
|
+
version_requirement:
|
97
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.3.0
|
102
|
+
version:
|
metadata.gz.sig
ADDED
Binary file
|