mailsmtp 0.2.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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +22 -0
- data/LICENSE +21 -0
- data/README.md +215 -0
- data/lib/mailsmtp/data_reader.rb +238 -0
- data/lib/mailsmtp/error.rb +58 -0
- data/lib/mailsmtp/errors.rb +85 -0
- data/lib/mailsmtp/server.rb +1199 -0
- data/lib/mailsmtp/session.rb +63 -0
- data/lib/mailsmtp/version.rb +3 -0
- data/lib/mailsmtp.rb +10 -0
- data/mailsmtp.gemspec +37 -0
- metadata +85 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
module MailSmtp
|
|
2
|
+
# Per-connection state for one SMTP conversation: where the client is in the
|
|
3
|
+
# command sequence, who they authenticated as, and the envelope they are
|
|
4
|
+
# building. One Session lives for the life of a single connection and is
|
|
5
|
+
# handed to every hook on Server. Subclass via Server#build_session.
|
|
6
|
+
#
|
|
7
|
+
# Message bytes are not stored here — during DATA the engine passes a live
|
|
8
|
+
# +DataReader+ into +Server#receive+.
|
|
9
|
+
class Session
|
|
10
|
+
class Envelope
|
|
11
|
+
attr_accessor :from, :encoding_body, :encoding_utf8, :declared_size
|
|
12
|
+
attr_reader :to
|
|
13
|
+
|
|
14
|
+
def initialize
|
|
15
|
+
@to = []
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
attr_accessor :phase,
|
|
20
|
+
:local_ip, :remote_ip, :helo, :helo_response, :local_response,
|
|
21
|
+
:connected_at, :encrypted_at, :authenticated_at,
|
|
22
|
+
:authorization_id, :authentication_id, :auth_login_username,
|
|
23
|
+
:exceptions, :auth_failures, :proxy, :close_after_reply,
|
|
24
|
+
:tls_version, :tls_cipher
|
|
25
|
+
attr_reader :envelope
|
|
26
|
+
|
|
27
|
+
def initialize
|
|
28
|
+
@exceptions = 0
|
|
29
|
+
@auth_failures = 0
|
|
30
|
+
@proxy = nil
|
|
31
|
+
@close_after_reply = false
|
|
32
|
+
@tls_version = nil
|
|
33
|
+
@tls_cipher = nil
|
|
34
|
+
reset
|
|
35
|
+
@phase = :helo
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Clear the per-message state — envelope and command sequence — while
|
|
39
|
+
# keeping the connection and its authentication. Used on RSET and at the end
|
|
40
|
+
# of each accepted message.
|
|
41
|
+
def reset
|
|
42
|
+
@phase = :ready
|
|
43
|
+
@envelope = Envelope.new
|
|
44
|
+
@auth_login_username = nil
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Drop identity asserted before STARTTLS (RFC 3207 §4.2).
|
|
48
|
+
def reset_authentication
|
|
49
|
+
@authenticated_at = nil
|
|
50
|
+
@authorization_id = nil
|
|
51
|
+
@authentication_id = nil
|
|
52
|
+
@auth_login_username = nil
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def authenticated?
|
|
56
|
+
!authenticated_at.nil?
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def encrypted?
|
|
60
|
+
!encrypted_at.nil?
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
data/lib/mailsmtp.rb
ADDED
data/mailsmtp.gemspec
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require_relative "lib/mailsmtp/version"
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = "mailsmtp"
|
|
5
|
+
spec.version = MailSmtp::VERSION
|
|
6
|
+
spec.platform = Gem::Platform::RUBY
|
|
7
|
+
spec.required_ruby_version = ">= 3.3.4"
|
|
8
|
+
spec.authors = [ "Simon Lev" ]
|
|
9
|
+
spec.email = [ "support@postrider.dev" ]
|
|
10
|
+
|
|
11
|
+
spec.summary = "A Boring SMTP server for Ruby"
|
|
12
|
+
spec.description = "Receive email in your own app — no Postfix, no ESP required. Implements the SMTP protocol so you can plug in your own logic for auth, accepting mail, and storage."
|
|
13
|
+
|
|
14
|
+
spec.homepage = "https://github.com/mailpiece/mailsmtp"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
|
18
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
|
19
|
+
spec.metadata["bug_tracker_uri"] = "#{spec.homepage}/issues"
|
|
20
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
|
21
|
+
|
|
22
|
+
# Anchor to the gemspec directory so `gem build` from another cwd still packs files.
|
|
23
|
+
spec.files = Dir.chdir(__dir__) do
|
|
24
|
+
Dir[
|
|
25
|
+
"lib/**/*.rb",
|
|
26
|
+
"CHANGELOG.md",
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE",
|
|
29
|
+
"mailsmtp.gemspec"
|
|
30
|
+
]
|
|
31
|
+
end
|
|
32
|
+
spec.require_paths = [ "lib" ]
|
|
33
|
+
|
|
34
|
+
# Bundled gems since Ruby 3.4 / 4.0 — must be declared for clean consumer bundles.
|
|
35
|
+
spec.add_dependency "base64"
|
|
36
|
+
spec.add_dependency "logger"
|
|
37
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: mailsmtp
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Simon Lev
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: base64
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: logger
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
description: Receive email in your own app — no Postfix, no ESP required. Implements
|
|
41
|
+
the SMTP protocol so you can plug in your own logic for auth, accepting mail, and
|
|
42
|
+
storage.
|
|
43
|
+
email:
|
|
44
|
+
- support@postrider.dev
|
|
45
|
+
executables: []
|
|
46
|
+
extensions: []
|
|
47
|
+
extra_rdoc_files: []
|
|
48
|
+
files:
|
|
49
|
+
- CHANGELOG.md
|
|
50
|
+
- LICENSE
|
|
51
|
+
- README.md
|
|
52
|
+
- lib/mailsmtp.rb
|
|
53
|
+
- lib/mailsmtp/data_reader.rb
|
|
54
|
+
- lib/mailsmtp/error.rb
|
|
55
|
+
- lib/mailsmtp/errors.rb
|
|
56
|
+
- lib/mailsmtp/server.rb
|
|
57
|
+
- lib/mailsmtp/session.rb
|
|
58
|
+
- lib/mailsmtp/version.rb
|
|
59
|
+
- mailsmtp.gemspec
|
|
60
|
+
homepage: https://github.com/mailpiece/mailsmtp
|
|
61
|
+
licenses:
|
|
62
|
+
- MIT
|
|
63
|
+
metadata:
|
|
64
|
+
source_code_uri: https://github.com/mailpiece/mailsmtp
|
|
65
|
+
changelog_uri: https://github.com/mailpiece/mailsmtp/blob/main/CHANGELOG.md
|
|
66
|
+
bug_tracker_uri: https://github.com/mailpiece/mailsmtp/issues
|
|
67
|
+
rubygems_mfa_required: 'true'
|
|
68
|
+
rdoc_options: []
|
|
69
|
+
require_paths:
|
|
70
|
+
- lib
|
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 3.3.4
|
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
|
+
requirements:
|
|
78
|
+
- - ">="
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: '0'
|
|
81
|
+
requirements: []
|
|
82
|
+
rubygems_version: 4.0.3
|
|
83
|
+
specification_version: 4
|
|
84
|
+
summary: A Boring SMTP server for Ruby
|
|
85
|
+
test_files: []
|