mailcatcher-ng 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b76a8adf417f26e41c5f224b9fc7d521c4be7ac4c23daec6b43d3e8eefbc041d
4
+ data.tar.gz: 50bdf55859d53c445390ee4c423388220ce339315bd05f2433825114f6777071
5
+ SHA512:
6
+ metadata.gz: a5593236368a57dc543bf39639e84671ff12982de1f24761053188569dad2c441f858f494486def40d1f46ffa499fe2f4b5e9fd63effa22d42b88b11e9565ce9
7
+ data.tar.gz: b3e78add1e2465484218a86b6e8ff4be0ac99ddf276c18d7192e2588c595b43833a3e9198a5e998ff2309fac4ccbedd18f795d0a97bcc2fc4c1ef08773e92e28
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010-2011 Samuel Cochran
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,235 @@
1
+ # MailCatcher NG (Next Generation)
2
+
3
+ [![Gem Version](https://img.shields.io/gem/v/mailcatcher-ng)](https://rubygems.org/gems/mailcatcher-ng)
4
+ [![CI](https://github.com/spaquet/mailcatcher-ng/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/spaquet/mailcatcher-ng/actions/workflows/ci.yml)
5
+ [![GitHub License](https://img.shields.io/github/license/spaquet/mailcatcher-ng)](LICENSE)
6
+
7
+ Catches mail and serves it through a dream.
8
+
9
+ MailCatcher NG runs a super simple SMTP server which catches any message sent to it to display in a web interface. Run mailcatcher, set your favourite app to deliver to smtp://127.0.0.1:1025 instead of your default SMTP server, then check out http://127.0.0.1:1080 to see the mail that's arrived so far.
10
+
11
+ ![MailCatcher screenshot](screenshots/inbox.webp)
12
+
13
+
14
+ ## Features
15
+
16
+ * Catches all mail and stores it for display.
17
+ * Shows HTML, Plain Text and Source version of messages, as applicable.
18
+ * Rewrites HTML enabling display of embedded, inline images/etc and opens links in a new window.
19
+ * Lists attachments and allows separate downloading of parts.
20
+ * Download original email to view in your native mail client(s).
21
+ * Command line options to override the default SMTP/HTTP IP and port settings.
22
+ * Mail appears instantly if your browser supports [WebSockets][websockets] with automatic reconnection and exponential backoff, otherwise updates every thirty seconds.
23
+ * Runs as a daemon in the background, optionally in foreground.
24
+ * Sendmail-analogue command, `catchmail`, makes using mailcatcher from PHP a lot easier.
25
+ * Keyboard navigation between messages
26
+ * Email authentication verification (DMARC, DKIM, SPF)
27
+ * Email encryption and signature support (S/MIME and OpenPGP)
28
+ * BIMI (Brand Indicators for Message Identification) display
29
+ * Advanced preview text extraction with intelligent fallback
30
+
31
+ For a comprehensive list of all features, see [FEATURES.md](FEATURES.md).
32
+
33
+ ## How
34
+
35
+ 1. `gem install mailcatcher-ng`
36
+ 2. `mailcatcher`
37
+ 3. Go to http://127.0.0.1:1080/
38
+ 4. Send mail through smtp://127.0.0.1:1025
39
+
40
+ ### Development Mode
41
+
42
+ To run MailCatcher in development mode with custom ports:
43
+
44
+ ```bash
45
+ MAILCATCHER_ENV=development bundle exec mailcatcher --foreground --smtp-port 1025 --http-port 1080
46
+ ```
47
+
48
+ Then access the web interface at [http://127.0.0.1:1080](http://127.0.0.1:1080) and send mail to `smtp://127.0.0.1:1025`.
49
+
50
+ Or use the provided test script to send example emails:
51
+
52
+ ```bash
53
+ SMTP_HOST=127.0.0.1 SMTP_PORT=20025 ruby send_example_emails.rb
54
+ ```
55
+
56
+ ### WebSocket Testing
57
+
58
+ To monitor WebSocket connectivity and test the connection status, visit [http://127.0.0.1:1080/websocket-test](http://127.0.0.1:1080/websocket-test). This page provides real-time feedback on WebSocket connection state and helps verify that automatic reconnection with exponential backoff is functioning correctly.
59
+
60
+ ### Command Line Options
61
+
62
+ Use `mailcatcher --help` to see the command line options.
63
+
64
+ ```
65
+ Usage: mailcatcher [options]
66
+
67
+ MailCatcher v0.11.2
68
+
69
+ --ip IP Set the ip address of both servers
70
+ --smtp-ip IP Set the ip address of the smtp server
71
+ --smtp-port PORT Set the port of the smtp server
72
+ --http-ip IP Set the ip address of the http server
73
+ --http-port PORT Set the port address of the http server
74
+ --messages-limit COUNT Only keep up to COUNT most recent messages
75
+ --http-path PATH Add a prefix to all HTTP paths
76
+ --no-quit Don't allow quitting the process
77
+ -f, --foreground Run in the foreground
78
+ -b, --browse Open web browser
79
+ -v, --verbose Be more verbose
80
+ -h, --help Display this help information
81
+ --version Display the current version
82
+ ```
83
+
84
+ ### Upgrading
85
+
86
+ Upgrading works the same as installation:
87
+
88
+ ```
89
+ gem install mailcatcher
90
+ ```
91
+
92
+ ### Ruby
93
+
94
+ If you have trouble with the setup commands, make sure you have [Ruby installed](https://www.ruby-lang.org/en/documentation/installation/):
95
+
96
+ ```
97
+ ruby -v
98
+ gem environment
99
+ ```
100
+
101
+ You might need to install build tools for some of the gem dependencies. On Debian or Ubuntu, `apt install build-essential`. On macOS, `xcode-select --install`.
102
+
103
+ ### How to Compile the Gem
104
+
105
+ To compile MailCatcher as a gem from source:
106
+
107
+ 1. Clone the repository:
108
+
109
+ ```bash
110
+ git clone https://github.com/spaquet/mailcatcher.git
111
+ cd mailcatcher
112
+ ```
113
+
114
+ 1. Install dependencies:
115
+
116
+ ```bash
117
+ bundle install
118
+ ```
119
+
120
+ 1. Compile assets and build the gem:
121
+
122
+ ```bash
123
+ bundle exec rake package
124
+ ```
125
+
126
+ This will create a `.gem` file in the project directory. The build process:
127
+
128
+ * Compiles JavaScript assets using Sprockets and Uglifier
129
+ * Creates a gem package with all required files
130
+
131
+ You can then install the compiled gem locally:
132
+
133
+ ```bash
134
+ gem install mailcatcher-VERSION.gem
135
+ ```
136
+
137
+ ### Bundler
138
+
139
+ Please don't put mailcatcher into your Gemfile. It will conflict with your application's gems at some point.
140
+
141
+ Instead, pop a note in your README stating you use mailcatcher, and to run `gem install mailcatcher` then `mailcatcher` to get started.
142
+
143
+ ### RVM
144
+
145
+ Under RVM your mailcatcher command may only be available under the ruby you install mailcatcher into. To prevent this, and to prevent gem conflicts, install mailcatcher into a dedicated gemset with a wrapper script:
146
+
147
+ rvm default@mailcatcher --create do gem install mailcatcher
148
+ ln -s "$(rvm default@mailcatcher do rvm wrapper show mailcatcher)" "$rvm_bin_path/"
149
+
150
+ ### Rails
151
+
152
+ To set up your rails app, I recommend adding this to your `environments/development.rb`:
153
+
154
+ config.action_mailer.delivery_method = :smtp
155
+ config.action_mailer.smtp_settings = { :address => '127.0.0.1', :port => 1025 }
156
+ config.action_mailer.raise_delivery_errors = false
157
+
158
+ ### PHP
159
+
160
+ For projects using PHP, or PHP frameworks and application platforms like Drupal, you can set [PHP's mail configuration](https://www.php.net/manual/en/mail.configuration.php) in your [php.ini](https://www.php.net/manual/en/configuration.file.php) to send via MailCatcher with:
161
+
162
+ sendmail_path = /usr/bin/env catchmail -f some@from.address
163
+
164
+ You can do this in your [Apache configuration](https://www.php.net/manual/en/configuration.changes.php) like so:
165
+
166
+ php_admin_value sendmail_path "/usr/bin/env catchmail -f some@from.address"
167
+
168
+ If you've installed via RVM this probably won't work unless you've manually added your RVM bin paths to your system environment's PATH. In that case, run `which catchmail` and put that path into the `sendmail_path` directive above instead of `/usr/bin/env catchmail`.
169
+
170
+ If starting `mailcatcher` on alternative SMTP IP and/or port with parameters like `--smtp-ip 192.168.0.1 --smtp-port 10025`, add the same parameters to your `catchmail` command:
171
+
172
+ sendmail_path = /usr/bin/env catchmail --smtp-ip 192.160.0.1 --smtp-port 10025 -f some@from.address
173
+
174
+ ### Django
175
+
176
+ For use in Django, add the following configuration to your projects' settings.py
177
+
178
+ ```python
179
+ if DEBUG:
180
+ EMAIL_HOST = '127.0.0.1'
181
+ EMAIL_HOST_USER = ''
182
+ EMAIL_HOST_PASSWORD = ''
183
+ EMAIL_PORT = 1025
184
+ EMAIL_USE_TLS = False
185
+ ```
186
+
187
+ ### Docker
188
+
189
+ The official MailCatcher Docker image is available [on Docker Hub](https://hub.docker.com/r/stpaquet/alpinemailcatcher):
190
+
191
+ ```
192
+ $ docker run -d -p 1080:1080 -p 1025:1025 stpaquet/alpinemailcatcher
193
+ Unable to find image 'stpaquet/alpinemailcatcher:latest' locally
194
+ latest: Pulling from stpaquet/alpinemailcatcher
195
+ 4abcf2090661: Pull complete
196
+ 9f403268fa96: Pull complete
197
+ 6c9f5f5b4c6d: Pull complete
198
+ Digest: sha256:a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0
199
+ Status: Downloaded newer image for stpaquet/alpinemailcatcher:latest
200
+ Starting MailCatcher v0.12.0
201
+ ==> smtp://0.0.0.0:1025
202
+ ==> http://0.0.0.0:1080
203
+ ```
204
+
205
+ How those ports appear and can be accessed may vary based on your Docker configuration. For example, you may need to use `http://127.0.0.1:1080` or `smtp://127.0.0.1:1025` instead of the listed address. The image is Alpine Linux based for minimal size and quick startup.
206
+
207
+ ### API
208
+
209
+ A fairly RESTful URL schema means you can download a list of messages in JSON from `/messages`, each message's metadata with `/messages/:id.json`, and then the pertinent parts with `/messages/:id.html` and `/messages/:id.plain` for the default HTML and plain text version, `/messages/:id/parts/:cid` for individual attachments by CID, or the whole message with `/messages/:id.source`.
210
+
211
+ ## Caveats
212
+
213
+ * Mail processing is fairly basic but easily modified. If something doesn't work for you, fork and fix it or [file an issue](https://github.com/spaquet/mailcatcher-ng/issues). Include the whole message you're having problems with.
214
+ * Encodings are difficult. MailCatcher NG does not completely support utf-8 straight over the wire, you must use a mail library which encodes things properly based on SMTP server capabilities.
215
+
216
+ ## License
217
+
218
+ MailCatcher NG is released under the MIT License, see [LICENSE](LICENSE) for details.
219
+
220
+ ## Credits
221
+
222
+ MailCatcher NG is a significantly improved fork of the original MailCatcher project. We've added many advanced features including:
223
+
224
+ * Email authentication verification (DMARC, DKIM, SPF)
225
+ * Email encryption and signature display (S/MIME and OpenPGP)
226
+ * BIMI (Brand Indicators for Message Identification) support
227
+ * Advanced preview text extraction with 3-tier fallback system
228
+ * Enhanced sender/recipient name parsing and display
229
+ * Improved UI/UX with keyboard navigation and better filtering
230
+ * WebSocket real-time updates with automatic reconnection
231
+ * And many more improvements to the original codebase
232
+
233
+ The original MailCatcher project was created by Samuel Cochran and released under the MIT License. We're grateful for this solid foundation and have built upon it to create MailCatcher NG.
234
+
235
+ [websockets]: https://tools.ietf.org/html/rfc6455
data/bin/catchmail ADDED
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ begin
5
+ require 'mail'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'mail'
9
+ end
10
+
11
+ require 'optparse'
12
+
13
+ options = {:smtp_ip => '127.0.0.1', :smtp_port => 1025}
14
+
15
+ OptionParser.new do |parser|
16
+ parser.banner = <<-BANNER.gsub /^ +/, ""
17
+ Usage: catchmail [options] [recipient ...]
18
+ sendmail-like interface to forward mail to MailCatcher.
19
+ BANNER
20
+
21
+ parser.on('--ip IP') do |ip|
22
+ options[:smtp_ip] = ip
23
+ end
24
+
25
+ parser.on('--smtp-ip IP', 'Set the ip address of the smtp server') do |ip|
26
+ options[:smtp_ip] = ip
27
+ end
28
+
29
+ parser.on('--smtp-port PORT', Integer, 'Set the port of the smtp server') do |port|
30
+ options[:smtp_port] = port
31
+ end
32
+
33
+ parser.on('-f FROM', 'Set the sending address') do |from|
34
+ options[:from] = from
35
+ end
36
+
37
+ parser.on('-oi', 'Ignored option -oi') do |ignored|
38
+ end
39
+ parser.on('-t', 'Ignored option -t') do |ignored|
40
+ end
41
+ parser.on('-q', 'Ignored option -q') do |ignored|
42
+ end
43
+
44
+ parser.on('-x', '--no-exit', 'Can\'t exit from the application') do
45
+ options[:no_exit] = true
46
+ end
47
+
48
+ parser.on('-h', '--help', 'Display this help information') do
49
+ puts parser
50
+ exit!
51
+ end
52
+ end.parse!
53
+
54
+ Mail.defaults do
55
+ delivery_method :smtp,
56
+ :address => options[:smtp_ip],
57
+ :port => options[:smtp_port]
58
+ end
59
+
60
+ message = Mail.new($stdin.read)
61
+
62
+ message.return_path = options[:from] if options[:from]
63
+
64
+ ARGV.each do |recipient|
65
+ if message.to.nil?
66
+ message.to = recipient
67
+ else
68
+ message.to << recipient
69
+ end
70
+ end
71
+
72
+ message.deliver
data/bin/mailcatcher ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'mail_catcher'
5
+
6
+ MailCatcher.run!
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "eventmachine"
4
+
5
+ module MailCatcher
6
+ Bus = EventMachine::Channel.new
7
+ end