simple_relay 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env +3 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +72 -0
- data/Guardfile +15 -0
- data/LICENSE +20 -0
- data/LICENSE.txt +22 -0
- data/README.md +23 -0
- data/Rakefile +1 -0
- data/bin/simple_relay +65 -0
- data/example.yml +16 -0
- data/lib/simple_relay.rb +39 -0
- data/lib/simple_relay/version.rb +3 -0
- data/simple_relay.gemspec +29 -0
- data/spec/spec_helper.rb +3 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3d2645d88dd3e092637afa340c059f9a4f603ef4
|
4
|
+
data.tar.gz: 549d677479d476ed48938c8d03ccb36ef89ffbfb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 496647d174d576a48d4643059461af3ec1794a2696285ec3b03e3b4934801fc781f6a8b73248414a755449ad616af7f4bcdc9d4ec2fbb22d7168d5a09c69302b
|
7
|
+
data.tar.gz: f52dd87ac562438f8b7abcf6f5b695b8cc7413a4de2d5cdc01b05b074b26d7d2b5e68503de8847ac51a3fddc15f556fb04fcb9f098ffd5712e13df5dbf58ebd7
|
data/.env
ADDED
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
simple_relay (0.0.1)
|
5
|
+
eventmachine
|
6
|
+
mail
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
celluloid (0.15.2)
|
12
|
+
timers (~> 1.1.0)
|
13
|
+
coderay (1.0.9)
|
14
|
+
diff-lcs (1.2.4)
|
15
|
+
eventmachine (1.0.3)
|
16
|
+
ffi (1.9.0)
|
17
|
+
formatador (0.2.4)
|
18
|
+
guard (2.2.2)
|
19
|
+
formatador (>= 0.2.4)
|
20
|
+
listen (~> 2.1)
|
21
|
+
lumberjack (~> 1.0)
|
22
|
+
pry (>= 0.9.12)
|
23
|
+
thor (>= 0.18.1)
|
24
|
+
guard-bundler (0.1.3)
|
25
|
+
bundler (>= 1.0.0)
|
26
|
+
guard (>= 0.2.2)
|
27
|
+
guard-rspec (4.0.3)
|
28
|
+
guard (>= 2.1.1)
|
29
|
+
rspec (~> 2.14)
|
30
|
+
listen (2.1.1)
|
31
|
+
celluloid (>= 0.15.2)
|
32
|
+
rb-fsevent (>= 0.9.3)
|
33
|
+
rb-inotify (>= 0.9)
|
34
|
+
lumberjack (1.0.4)
|
35
|
+
mail (2.5.4)
|
36
|
+
mime-types (~> 1.16)
|
37
|
+
treetop (~> 1.4.8)
|
38
|
+
method_source (0.8.2)
|
39
|
+
mime-types (1.25)
|
40
|
+
polyglot (0.3.3)
|
41
|
+
pry (0.9.12.2)
|
42
|
+
coderay (~> 1.0.5)
|
43
|
+
method_source (~> 0.8)
|
44
|
+
slop (~> 3.4)
|
45
|
+
rake (10.1.0)
|
46
|
+
rb-fsevent (0.9.3)
|
47
|
+
rb-inotify (0.9.2)
|
48
|
+
ffi (>= 0.5.0)
|
49
|
+
rspec (2.14.1)
|
50
|
+
rspec-core (~> 2.14.0)
|
51
|
+
rspec-expectations (~> 2.14.0)
|
52
|
+
rspec-mocks (~> 2.14.0)
|
53
|
+
rspec-core (2.14.6)
|
54
|
+
rspec-expectations (2.14.3)
|
55
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
56
|
+
rspec-mocks (2.14.4)
|
57
|
+
slop (3.4.6)
|
58
|
+
thor (0.18.1)
|
59
|
+
timers (1.1.0)
|
60
|
+
treetop (1.4.15)
|
61
|
+
polyglot
|
62
|
+
polyglot (>= 0.3.1)
|
63
|
+
|
64
|
+
PLATFORMS
|
65
|
+
ruby
|
66
|
+
|
67
|
+
DEPENDENCIES
|
68
|
+
bundler (~> 1.3)
|
69
|
+
guard-bundler
|
70
|
+
guard-rspec
|
71
|
+
rake
|
72
|
+
simple_relay!
|
data/Guardfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
|
5
|
+
guard 'bundler' do
|
6
|
+
watch('Gemfile')
|
7
|
+
watch(/^.+\.gemspec/)
|
8
|
+
end
|
9
|
+
|
10
|
+
guard 'rspec' do
|
11
|
+
watch(%r{^spec/.+_spec\.rb$})
|
12
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
13
|
+
watch('spec/spec_helper.rb') { "spec" }
|
14
|
+
end
|
15
|
+
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Verestiuc Vlad
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Vlad Verestiuc
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
# SimpleRelay
|
3
|
+
|
4
|
+
Uses different SMTP accounts based on the sender of the message
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem install simple_relay
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
```shell
|
15
|
+
$ simple_relay configure
|
16
|
+
$ vim ~/.simple_relay.yml
|
17
|
+
$ simple_relay install
|
18
|
+
$ launchctl load ~/Library/LaunchAgents/com.github.vvlad.simple_relay.plist
|
19
|
+
$ lsof -p :1025
|
20
|
+
```
|
21
|
+
|
22
|
+
Configure your email client to use the relay server
|
23
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/simple_relay
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$: << File.expand_path("../../lib", __FILE__)
|
4
|
+
require 'simple_relay'
|
5
|
+
require 'yaml'
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
def start_server
|
12
|
+
config = YAML.load_file("#{ENV["HOME"]}/.simple_relay.yml")
|
13
|
+
EM.run do
|
14
|
+
EM.start_server config.fetch("listen","127.0.0.1"), config.fetch("port",1025), SimpleRelay::Server do |server|
|
15
|
+
|
16
|
+
server.accounts = config.fetch("accounts",{})
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
$OS = `uname -s 2>/dev/null`.strip
|
24
|
+
|
25
|
+
case ARGV.first
|
26
|
+
when "configure" then FileUtils.cp(File.expand_path("../../example.yml", __FILE__) , "#{ENV["HOME"]}/.simple_relay.yml")
|
27
|
+
when "start" then start_server
|
28
|
+
when "install" then
|
29
|
+
if $OS =~ /Darwin/
|
30
|
+
plist = <<-XML
|
31
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
32
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
33
|
+
<plist version="1.0">
|
34
|
+
<dict>
|
35
|
+
<key>KeepAlive</key>
|
36
|
+
<dict>
|
37
|
+
<key>SuccessfulExit</key>
|
38
|
+
<false/>
|
39
|
+
</dict>
|
40
|
+
<key>Label</key>
|
41
|
+
<string>com.github.vvlad.simple_relay</string>
|
42
|
+
<key>ProgramArguments</key>
|
43
|
+
<array>
|
44
|
+
<string>#{RbConfig.ruby}</string>
|
45
|
+
<string>#{__FILE__}</string>
|
46
|
+
</array>
|
47
|
+
<key>RunAtLoad</key>
|
48
|
+
<true/>
|
49
|
+
<key>WorkingDirectory</key>
|
50
|
+
<string>#{File.expand_path("../..", __FILE__)}</string>
|
51
|
+
<key>StandardErrorPath</key>
|
52
|
+
<string>#{ENV["HOME"]}/Library/Logs/simple_relay.log</string>
|
53
|
+
<key>StandardOutPath</key>
|
54
|
+
<string>#{ENV["HOME"]}/Library/Logs/simple_relay.log</string>
|
55
|
+
</dict>
|
56
|
+
</plist>
|
57
|
+
XML
|
58
|
+
open("#{ENV["HOME"]}/Library/LaunchAgents/com.github.vvlad.simple_relay.plist","w") do |f|
|
59
|
+
f << plist
|
60
|
+
end
|
61
|
+
else
|
62
|
+
puts "#{$OS} not supported"
|
63
|
+
end
|
64
|
+
else start_server
|
65
|
+
end
|
data/example.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
listen: 127.0.0.1
|
3
|
+
port: 1025
|
4
|
+
|
5
|
+
accounts:
|
6
|
+
# "vlad.verestiuc@me.com":
|
7
|
+
# starttls: true
|
8
|
+
# host: smtp.mail.me.com
|
9
|
+
# port: 587
|
10
|
+
# auth:
|
11
|
+
# type: :plain
|
12
|
+
# username: vlad.verestiuc@me.com
|
13
|
+
# password: *****
|
14
|
+
# domain: me.com
|
15
|
+
# verbose: true
|
16
|
+
|
data/lib/simple_relay.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#require "simple_relay/version"
|
2
|
+
|
3
|
+
require 'eventmachine'
|
4
|
+
require 'mail'
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
module SimpleRelay
|
8
|
+
class Client < EM::P::SmtpClient
|
9
|
+
|
10
|
+
def invoke_mail_from
|
11
|
+
super
|
12
|
+
proxy_incoming_to(@args[:connection])
|
13
|
+
@args[:connection].proxy_incoming_to(self)
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
class Server < EM::P::SmtpServer
|
20
|
+
|
21
|
+
attr_accessor :accounts
|
22
|
+
|
23
|
+
def process_mail_from sender
|
24
|
+
sender = Mail::Address.new(sender).address
|
25
|
+
if account = accounts[sender]
|
26
|
+
account = account.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
27
|
+
account[:auth] = account[:auth].inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
28
|
+
Client.send account.merge( connection: self, from: sender )
|
29
|
+
else
|
30
|
+
send_data "550 sender is not matching any known accounts #{@accounts.keys.join(",")}\r\n"
|
31
|
+
close_connection_after_writing
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'simple_relay/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "simple_relay"
|
8
|
+
spec.version = SimpleRelay::VERSION
|
9
|
+
spec.authors = ["Vlad Verestiuc"]
|
10
|
+
spec.email = ["verestiuc.vlad@gmail.com"]
|
11
|
+
spec.description = %q{A simple SMTP relay tool}
|
12
|
+
spec.summary = %q{Uses different SMTP accounts based on the sender of the message}
|
13
|
+
spec.homepage = "https://github.com/vvlad/simple_relay"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "eventmachine"
|
22
|
+
spec.add_dependency "mail"
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "guard-rspec"
|
26
|
+
spec.add_development_dependency "guard-bundler"
|
27
|
+
|
28
|
+
spec.executables = ["simple_relay"]
|
29
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simple_relay
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vlad Verestiuc
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: eventmachine
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mail
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard-bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: A simple SMTP relay tool
|
98
|
+
email:
|
99
|
+
- verestiuc.vlad@gmail.com
|
100
|
+
executables:
|
101
|
+
- simple_relay
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- .env
|
106
|
+
- .gitignore
|
107
|
+
- Gemfile
|
108
|
+
- Gemfile.lock
|
109
|
+
- Guardfile
|
110
|
+
- LICENSE
|
111
|
+
- LICENSE.txt
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- bin/simple_relay
|
115
|
+
- example.yml
|
116
|
+
- lib/simple_relay.rb
|
117
|
+
- lib/simple_relay/version.rb
|
118
|
+
- simple_relay.gemspec
|
119
|
+
- spec/spec_helper.rb
|
120
|
+
homepage: https://github.com/vvlad/simple_relay
|
121
|
+
licenses:
|
122
|
+
- MIT
|
123
|
+
metadata: {}
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - '>='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
requirements: []
|
139
|
+
rubyforge_project:
|
140
|
+
rubygems_version: 2.0.3
|
141
|
+
signing_key:
|
142
|
+
specification_version: 4
|
143
|
+
summary: Uses different SMTP accounts based on the sender of the message
|
144
|
+
test_files:
|
145
|
+
- spec/spec_helper.rb
|