fakemail 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +38 -0
- data/bin/fakemail +8 -0
- data/fakemail.gemspec +15 -0
- data/lib/fakemail.rb +46 -0
- metadata +51 -0
data/README.rdoc
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
= Fakemail
|
2
|
+
|
3
|
+
Fakemail is a simple sendmail replacement made for debugging/inpection purposes.
|
4
|
+
|
5
|
+
== Features
|
6
|
+
|
7
|
+
* Works in any Ruby app (Rails/Mer/Sinatra)
|
8
|
+
* Stores each email as 2 files: headers and content.
|
9
|
+
* Both text and html formats are supported.
|
10
|
+
|
11
|
+
== Installation
|
12
|
+
|
13
|
+
Install as a gem:
|
14
|
+
|
15
|
+
gem install fakemail
|
16
|
+
|
17
|
+
== Usage
|
18
|
+
|
19
|
+
To see where the actual script is:
|
20
|
+
|
21
|
+
which fakemail
|
22
|
+
|
23
|
+
=== Usage: Rails
|
24
|
+
|
25
|
+
# RAILS_ROOT/config/environments/development.rb
|
26
|
+
config.action_mailer.delivery_method = :sendmail
|
27
|
+
config.action_mailer.sendmail_settings = {:location => "PATH_TO_FAKEMAIL"}
|
28
|
+
|
29
|
+
Restart the app, and its ready to go.
|
30
|
+
|
31
|
+
=== Usage: Pony
|
32
|
+
|
33
|
+
Pony.mail(
|
34
|
+
:via => :sendmail,
|
35
|
+
:via_options => {
|
36
|
+
:location => 'PATH_TO_FAKEMAIL',
|
37
|
+
}
|
38
|
+
)
|
data/bin/fakemail
ADDED
data/fakemail.gemspec
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "fakemail"
|
3
|
+
s.version = "0.2.0"
|
4
|
+
s.summary = "Sendmail replacement to debug email output."
|
5
|
+
s.description = "Provides a fake sendmail binary to store email output for email dubugging purposes."
|
6
|
+
s.homepage = "http://github.com/sosedoff/fakemail"
|
7
|
+
s.authors = ["Dan Sosedoff"]
|
8
|
+
s.email = ["dan.sosedoff@gmail.com"]
|
9
|
+
|
10
|
+
s.files = `git ls-files`.split("\n")
|
11
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
12
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
|
13
|
+
s.require_paths = ["lib"]
|
14
|
+
s.default_executable = 'fakemail'
|
15
|
+
end
|
data/lib/fakemail.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Fakemail
|
4
|
+
DEFAULT_PATH = '/tmp/fakemail'
|
5
|
+
|
6
|
+
class << self
|
7
|
+
# Set a new output path for emails
|
8
|
+
#
|
9
|
+
def output_path= (path)
|
10
|
+
@output_path = path
|
11
|
+
end
|
12
|
+
|
13
|
+
# Get current emails output path
|
14
|
+
#
|
15
|
+
def output_path
|
16
|
+
@output_path ||= DEFAULT_PATH
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Mail
|
21
|
+
# Initialize a mail with input
|
22
|
+
#
|
23
|
+
def initialize(stream=nil)
|
24
|
+
headers = ''
|
25
|
+
body = ''
|
26
|
+
|
27
|
+
stream.each_line { |l| headers << l ; break if l.strip.empty? }
|
28
|
+
stream.each_line { |l| body << l }
|
29
|
+
|
30
|
+
format = headers =~ /text\/html/i ? 'html' : 'txt'
|
31
|
+
filename = Time.now.to_i
|
32
|
+
|
33
|
+
setup
|
34
|
+
|
35
|
+
File.open("#{@dir}/#{filename}_headers.txt", "w") { |f| f.write(headers) }
|
36
|
+
File.open("#{@dir}/#{filename}.#{format}", "w") { |f| f.write(body) }
|
37
|
+
end
|
38
|
+
|
39
|
+
# Setup an output path
|
40
|
+
#
|
41
|
+
def setup
|
42
|
+
@dir = Fakemail.output_path
|
43
|
+
FileUtils.mkdir_p(@dir)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fakemail
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dan Sosedoff
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-10-24 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: Provides a fake sendmail binary to store email output for email dubugging
|
15
|
+
purposes.
|
16
|
+
email:
|
17
|
+
- dan.sosedoff@gmail.com
|
18
|
+
executables:
|
19
|
+
- fakemail
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- README.rdoc
|
24
|
+
- bin/fakemail
|
25
|
+
- fakemail.gemspec
|
26
|
+
- lib/fakemail.rb
|
27
|
+
homepage: http://github.com/sosedoff/fakemail
|
28
|
+
licenses: []
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
requirements: []
|
46
|
+
rubyforge_project:
|
47
|
+
rubygems_version: 1.8.10
|
48
|
+
signing_key:
|
49
|
+
specification_version: 3
|
50
|
+
summary: Sendmail replacement to debug email output.
|
51
|
+
test_files: []
|