mailcat 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4bb7968127c9678b2385d8f1de093120bf5e0365e823328ae3478f4d481d485e
4
- data.tar.gz: f6f6c3f6e718daad7832aa18d85be765e6bc1e37802e2de8da5b01c6ea898c1a
3
+ metadata.gz: a50e06c4b60175ae61f8551df83593d71095f3130d4358797caf2aaee1ef16c3
4
+ data.tar.gz: 12c8693b3626069bd0925ad0e243cecb46227356b6a94e9c568611e4bd0bc20c
5
5
  SHA512:
6
- metadata.gz: e5af544b05be27470c85800e560cf8b9a7e7476cd55661306b4006742434fb8fe2c59eaf4a59bf16530bcea2ae25843d2918411d0a416c2f7a698dc6fe995111
7
- data.tar.gz: 66a48c93de2ecd53d9545b9e1c86f8ade902af09d6256fbea98f2f03592f8983183ce2f96d8724035118aa5d4bd1fdf59e1b849484c375fc190c9caf55da66d5
6
+ metadata.gz: 8f06b3446deaf7d9f083a198208402982679354bc1ab4e8bae2d8013d2d91e04b8b9ea7fab0258e8f5e265ac174ffb5be3aa7795c744f732a99be4d437dfe7e9
7
+ data.tar.gz: 8857bd54fdc8b3d1c7c4b459493303a438495d1e5d0938ffca2eb7b6b3fbab9c43233a4f35e9e06413ff71a47b2201a3f8e773f05b07d02b033921f44ab9def5
data/README.md CHANGED
@@ -1,24 +1,98 @@
1
1
  # Mailcat
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ A Rails gem that integrates with [Mailcat.app](https://mailcat.app) to easily test your emails in staging and visualize them in a beautiful web interface. Instead of actually sending emails, Mailcat captures them and displays them in your Mailcat dashboard.
4
4
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/mailcat`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+ ## Features
6
+
7
+ - 🚀 **Zero Configuration**: Automatically registers as an ActionMailer delivery method
8
+ - 📎 **Attachment Support**: Handles email attachments seamlessly
9
+ - 📧 **Multi-format Support**: Works with both HTML and plain text emails
10
+ - ⚙️ **Flexible Configuration**: Configure via environment variables or explicit configuration
11
+ - 🔒 **Secure**: Uses API keys for authentication
6
12
 
7
13
  ## Installation
8
14
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'mailcat'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ ```bash
24
+ $ bundle install
25
+ ```
26
+
27
+ Or install it yourself as:
28
+
29
+ ```bash
30
+ $ gem install mailcat
31
+ ```
32
+
33
+ ## Configuration
34
+
35
+ ### Environment Variables (Recommended)
36
+
37
+ The gem automatically reads configuration from environment variables:
38
+
39
+ ```bash
40
+ export MAILCAT_API_KEY=your_api_key_here
41
+ export MAILCAT_URL=https://mailcat.app
42
+ ```
10
43
 
11
- Install the gem and add to the application's Gemfile by executing:
44
+ ### Explicit Configuration
12
45
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
46
+ You can also configure Mailcat explicitly in your Rails initializer or environment files:
14
47
 
15
- If bundler is not being used to manage dependencies, install the gem by executing:
48
+ ```ruby
49
+ # config/initializers/mailcat.rb
50
+ Mailcat.configure do |config|
51
+ config.mailcat_api_key = "your_api_key_here"
52
+ config.mailcat_url = "https://mailcat.app"
53
+ end
54
+ ```
16
55
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
56
+ ### Setting the Delivery Method
57
+
58
+ Configure ActionMailer to use the Mailcat delivery method in your environment configuration:
59
+
60
+ ```ruby
61
+ # config/environments/staging.rb or config/environments/development.rb
62
+ Rails.application.configure do
63
+ config.action_mailer.delivery_method = :mailcat
64
+ config.action_mailer.perform_deliveries = true
65
+ end
66
+ ```
18
67
 
19
68
  ## Usage
20
69
 
21
- TODO: Write usage instructions here
70
+ Once configured, your Rails application will automatically send all emails through Mailcat instead of actually delivering them. No changes to your mailer code are required!
71
+
72
+ ```ruby
73
+ # app/mailers/user_mailer.rb
74
+ class UserMailer < ApplicationMailer
75
+ def welcome_email(user)
76
+ @user = user
77
+ mail(to: @user.email, subject: 'Welcome to our app!')
78
+ end
79
+ end
80
+ ```
81
+
82
+ The email will be captured and displayed in your Mailcat dashboard at the configured URL.
83
+
84
+ ### Features in Action
85
+
86
+ - **HTML and Text Content**: Both HTML and plain text parts are captured
87
+ - **Attachments**: Email attachments are automatically uploaded and linked
88
+ - **Headers**: All email headers (from, to, cc, bcc, subject) are preserved
89
+ - **Inline Attachments**: Attachments referenced in email content are properly handled
90
+
91
+ ## Requirements
92
+
93
+ - Ruby >= 3.0.0
94
+ - Rails >= 6.0.0
95
+ - ActiveSupport >= 6.0.0
22
96
 
23
97
  ## Development
24
98
 
@@ -28,7 +102,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
28
102
 
29
103
  ## Contributing
30
104
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mailcat. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/mailcat/blob/main/CODE_OF_CONDUCT.md).
105
+ Bug reports and pull requests are welcome on GitHub at https://github.com/gogrow-dev/mailcat. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/gogrow-dev/mailcat/blob/main/CODE_OF_CONDUCT.md).
32
106
 
33
107
  ## License
34
108
 
@@ -36,4 +110,13 @@ The gem is available as open source under the terms of the [MIT License](https:/
36
110
 
37
111
  ## Code of Conduct
38
112
 
39
- Everyone interacting in the Mailcat project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/mailcat/blob/main/CODE_OF_CONDUCT.md).
113
+ Everyone interacting in the Mailcat project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/gogrow-dev/mailcat/blob/main/CODE_OF_CONDUCT.md).
114
+
115
+ ---
116
+
117
+ <div align="center">
118
+ <p>Made with ❤️ by</p>
119
+ <a href="https://gogrow.dev">
120
+ <img src="assets/images/gogrow.svg" alt="GoGrow" width="120" />
121
+ </a>
122
+ </div>
data/assets/.DS_Store ADDED
Binary file
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="UTF-8"?><svg id="Layer_2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 394.98 63.47"><defs><style>.cls-1{fill:blue;}</style></defs><g id="Layer_1-2"><path class="cls-1" d="m213.2,55.47c-3.06.03-6.1-.59-8.9-1.81-2.72-1.19-5.18-2.91-7.21-5.06-2.08-2.2-3.72-4.78-4.83-7.59-1.18-3.01-1.77-6.21-1.74-9.43-.02-3.13.53-6.23,1.63-9.17,1.05-2.81,2.64-5.38,4.68-7.59,2.07-2.22,4.59-3.99,7.39-5.19,3.06-1.3,6.36-1.94,9.69-1.9,4.15.01,8.25.91,12.02,2.64,1.83.83,3.55,1.89,5.11,3.16l-4.27,7c-1.71-1.56-3.73-2.76-5.92-3.51-2.19-.81-4.5-1.23-6.84-1.24-2.01-.04-4.01.36-5.86,1.16-1.66.75-3.13,1.86-4.29,3.25-1.19,1.45-2.08,3.11-2.64,4.9-.62,1.97-.92,4.03-.9,6.09-.03,2.22.31,4.42,1.01,6.53.61,1.84,1.57,3.56,2.82,5.05,1.17,1.38,2.63,2.49,4.27,3.26,1.64.76,3.43,1.15,5.24,1.14,1.48,0,2.95-.25,4.34-.74,1.36-.46,2.62-1.17,3.73-2.08,1.07-.86,1.95-1.94,2.58-3.15.64-1.22.97-2.58.96-3.96v-.7h-12.1v-2.04l21.34-7.59v9.6c.03,2.66-.57,5.3-1.75,7.69-1.16,2.3-2.79,4.35-4.78,6-2.03,1.7-4.35,3.02-6.85,3.91-2.54.92-5.22,1.38-7.92,1.38h0Z"/><path class="cls-1" d="m161.81,55.61c-3.11.03-6.19-.6-9.04-1.84-2.77-1.2-5.29-2.94-7.39-5.11-4.38-4.54-6.82-10.61-6.82-16.92s2.45-12.37,6.82-16.92c2.11-2.17,4.62-3.91,7.39-5.11,2.86-1.21,5.93-1.84,9.04-1.84s6.18.63,9.04,1.84c2.78,1.2,5.29,2.94,7.39,5.11,2.12,2.19,3.81,4.77,4.98,7.59,1.21,2.95,1.82,6.11,1.79,9.3.05,6.31-2.38,12.39-6.77,16.92-2.1,2.17-4.62,3.91-7.39,5.11-2.85,1.25-5.92,1.89-9.03,1.87Zm0-8.57c1.86.02,3.71-.36,5.41-1.11,1.63-.74,3.08-1.82,4.27-3.16,1.25-1.41,2.21-3.04,2.85-4.81.65-1.96.96-4.02.91-6.09.04-2.08-.28-4.15-.95-6.12-.64-1.75-1.61-3.36-2.85-4.74-1.87-2.02-4.32-3.41-7.02-3.98-2.7-.57-5.5-.28-8.03.82-1.63.74-3.09,1.82-4.27,3.16-1.25,1.4-2.22,3.04-2.85,4.81-.67,1.96-.99,4.02-.95,6.09-.04,2.07.28,4.13.95,6.09.63,1.77,1.59,3.41,2.85,4.81,1.18,1.35,2.64,2.42,4.28,3.16,1.69.74,3.52,1.1,5.37,1.07h.03Z"/><path class="cls-1" d="m305.66,55.61c-3.11.03-6.18-.6-9.03-1.84-2.78-1.2-5.29-2.94-7.39-5.11-4.39-4.53-6.82-10.61-6.78-16.92-.04-6.31,2.4-12.38,6.78-16.92,2.1-2.17,4.62-3.91,7.39-5.11,2.85-1.21,5.92-1.83,9.01-1.83s6.16.62,9.01,1.83c2.78,1.2,5.29,2.94,7.39,5.11,4.39,4.53,6.82,10.61,6.79,16.92.04,6.31-2.4,12.38-6.79,16.92-2.09,2.17-4.58,3.91-7.33,5.11-2.85,1.24-5.94,1.87-9.05,1.84h0Zm0-8.57c1.86.02,3.71-.36,5.41-1.11,1.63-.74,3.09-1.81,4.27-3.16,1.25-1.41,2.21-3.04,2.85-4.81.69-1.96,1.03-4.02,1.01-6.09,0-2.09-.36-4.16-1.06-6.12-.63-1.77-1.6-3.4-2.85-4.81-1.19-1.34-2.64-2.42-4.27-3.16-1.7-.73-3.54-1.11-5.39-1.11s-3.69.38-5.39,1.11c-1.63.76-3.08,1.86-4.25,3.23-1.25,1.4-2.22,3.04-2.85,4.81-.66,1.96-.98,4.02-.95,6.09-.03,2.07.29,4.13.95,6.09.63,1.77,1.59,3.41,2.85,4.81,1.19,1.34,2.64,2.42,4.28,3.16,1.69.74,3.52,1.1,5.37,1.07h.03Z"/><path class="cls-1" d="m344.49,54.69l-12.3-42.65-.95-3.23h10.01l8.68,33.53,7.94-27.22,1.84-6.31h6.75l.86,2.94,8.9,30.59,7.68-29.57,1.02-3.96h10.04l-13.24,45.87h-10l-8.63-28.5-7.39,24.48-1.21,4.02h-10.02Z"/><path class="cls-1" d="m264.53,36.37c2.02-.55,3.91-1.51,5.53-2.84,1.52-1.25,2.72-2.85,3.5-4.65.84-1.96,1.26-4.08,1.23-6.21.08-2.62-.57-5.21-1.89-7.47-1.28-2.07-3.15-3.71-5.36-4.73-2.56-1.16-5.35-1.72-8.16-1.65h-15.64v7.01h12.71c2.77,0,4.91.6,6.43,1.81.75.62,1.34,1.41,1.73,2.32.39.9.56,1.88.5,2.87.04,1.35-.32,2.68-1.03,3.82-.73,1.08-1.76,1.92-2.96,2.39-1.49.58-3.08.85-4.68.81h-3.78v-9.31l-8.92,3.29v30.87h8.92v-17.2h2.15l13.1,17.2h11.6l-2.59-3.17-12.39-15.15Z"/><path class="cls-1" d="m110.93,55.45c-3.08.03-6.12-.58-8.94-1.81-2.72-1.19-5.18-2.91-7.22-5.06-2.06-2.21-3.68-4.78-4.78-7.59-1.18-3-1.78-6.21-1.75-9.43-.02-3.13.53-6.23,1.63-9.17,1.05-2.81,2.65-5.39,4.69-7.59,2.08-2.24,4.61-4.02,7.42-5.22,3.06-1.29,6.36-1.94,9.69-1.9,4.15,0,8.25.91,12.02,2.64,1.81.84,3.51,1.91,5.04,3.18l-4.26,7c-1.71-1.56-3.72-2.75-5.91-3.5-2.19-.8-4.5-1.23-6.84-1.24-2.01-.04-4,.36-5.84,1.16-1.66.75-3.12,1.86-4.28,3.25-1.19,1.45-2.09,3.11-2.65,4.9-.61,1.97-.91,4.03-.9,6.09-.01,2.22.35,4.42,1.06,6.53.63,1.85,1.6,3.56,2.87,5.05,1.16,1.38,2.6,2.49,4.23,3.26,1.64.76,3.43,1.15,5.24,1.14,1.48,0,2.95-.25,4.34-.74,1.36-.46,2.62-1.17,3.72-2.08,1.05-.87,1.91-1.94,2.53-3.15.64-1.22.97-2.58.96-3.96v-.69h-12.1v-7.01h21.34v6.96c.03,2.66-.57,5.3-1.76,7.69-1.16,2.31-2.78,4.35-4.78,6-2.03,1.69-4.35,3.02-6.85,3.91-2.54.92-5.23,1.38-7.93,1.38Z"/><path class="cls-1" d="m70.67,16.03l-9.18,3.28-21.21-11.3-22.23,7.93,12.47,6.63,6.53-2.35-6.08-3.27,9.19-3.31,15.07,7.92-25.04,8.96L0,14.61,40.45,0l30.22,16.03Z"/><path class="cls-1" d="m71.21,17.53l-9.18,3.29-9.22,22.19-22.22,7.97,5.43-13.04,6.54-2.32-2.62,6.39,9.21-3.28,6.62-15.67-25.04,8.96-13.24,31.45,40.53-14.36,13.19-31.58Z"/></g></svg>
@@ -3,11 +3,7 @@
3
3
  module Mailcat
4
4
  # Rails delivery_method for Mailcat.
5
5
  class DeliveryMethod
6
- attr_accessor :settings
7
-
8
- def initialize(...)
9
- self.settings = Mailcat.config
10
- end
6
+ def initialize(settings = {}); end
11
7
 
12
8
  def deliver!(mail)
13
9
  send_to_mailcat(mail)
@@ -21,7 +17,7 @@ module Mailcat
21
17
  Net::HTTP.start(emails_uri.hostname, emails_uri.port, use_ssl: emails_uri.scheme == "https") do |http|
22
18
  req = Net::HTTP::Post.new(emails_uri)
23
19
  req["Content-Type"] = "application/json"
24
- req["X-Api-Key"] = Mailcat.mailcat_api_key_raw
20
+ req["X-Api-Key"] = Mailcat.config.mailcat_api_key
25
21
  email_body = {
26
22
  from: mail.from.first,
27
23
  to: mail.to,
@@ -62,7 +58,7 @@ module Mailcat
62
58
 
63
59
  req = Net::HTTP::Post.new(direct_uploads_uri)
64
60
  req["Content-Type"] = "application/json"
65
- req["X-Api-Key"] = Mailcat.mailcat_api_key_raw
61
+ req["X-Api-Key"] = Mailcat.config.mailcat_api_key
66
62
  req.body = {
67
63
  blob: {
68
64
  filename: attachment.filename,
@@ -82,11 +78,11 @@ module Mailcat
82
78
  end
83
79
 
84
80
  def emails_uri
85
- @emails_uri ||= URI("#{Mailcat.mailcat_url_raw}/api/emails")
81
+ @emails_uri ||= URI("#{Mailcat.config.mailcat_url}/api/emails")
86
82
  end
87
83
 
88
84
  def direct_uploads_uri
89
- @direct_uploads_uri ||= URI("#{Mailcat.mailcat_url_raw}/api/direct_uploads")
85
+ @direct_uploads_uri ||= URI("#{Mailcat.config.mailcat_url}/api/direct_uploads")
90
86
  end
91
87
 
92
88
  def attachment_tempfile(attachment)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mailcat
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
data/lib/mailcat.rb CHANGED
@@ -3,21 +3,26 @@
3
3
  require "mailcat/delivery_method"
4
4
  require "mailcat/railtie" if defined?(Rails::Railtie)
5
5
  require "mailcat/version"
6
- require "active_support"
7
6
 
8
7
  module Mailcat
9
8
  class Error < StandardError; end
10
9
 
11
- include ::ActiveSupport::Configurable
10
+ class Configuration
11
+ attr_accessor :mailcat_api_key, :mailcat_url
12
12
 
13
- config_accessor :mailcat_api_key, default: -> { ENV["MAILCAT_API_KEY"] }
14
- config_accessor :mailcat_url, default: -> { ENV["MAILCAT_URL"] }
15
-
16
- def self.mailcat_api_key_raw
17
- config.mailcat_api_key.is_a?(Proc) ? config.mailcat_api_key.call : config.mailcat_api_key
13
+ def initialize
14
+ @mailcat_api_key = ENV["MAILCAT_API_KEY"]
15
+ @mailcat_url = ENV["MAILCAT_URL"]
16
+ end
18
17
  end
19
18
 
20
- def self.mailcat_url_raw
21
- config.mailcat_url.is_a?(Proc) ? config.mailcat_url.call : config.mailcat_url
19
+ class << self
20
+ def config
21
+ @config ||= Configuration.new
22
+ end
23
+
24
+ def configure
25
+ yield config
26
+ end
22
27
  end
23
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailcat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Aparicio
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-04-25 00:00:00.000000000 Z
11
+ date: 2026-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -40,11 +40,12 @@ files:
40
40
  - LICENSE.txt
41
41
  - README.md
42
42
  - Rakefile
43
+ - assets/.DS_Store
44
+ - assets/images/gogrow.svg
43
45
  - lib/mailcat.rb
44
46
  - lib/mailcat/delivery_method.rb
45
47
  - lib/mailcat/railtie.rb
46
48
  - lib/mailcat/version.rb
47
- - mailcat.gemspec
48
49
  - sig/mailcat.rbs
49
50
  homepage: https://mailcat.app
50
51
  licenses:
@@ -68,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
69
  - !ruby/object:Gem::Version
69
70
  version: '0'
70
71
  requirements: []
71
- rubygems_version: 3.4.10
72
+ rubygems_version: 3.5.7
72
73
  signing_key:
73
74
  specification_version: 4
74
75
  summary: Mailcat app rails integration.
data/mailcat.gemspec DELETED
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/mailcat/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "mailcat"
7
- spec.version = Mailcat::VERSION
8
- spec.authors = ["Juan Aparicio"]
9
- spec.email = ["apariciojuan30@gmail.com"]
10
-
11
- spec.summary = "Mailcat app rails integration."
12
- spec.description = "Easily test your emails in staging and visualize them in https://mailcat.app ."
13
- spec.homepage = "https://mailcat.app"
14
- spec.license = "MIT"
15
- spec.required_ruby_version = ">= 3.0.0"
16
-
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = "https://github.com/gogrow-dev/mailcat"
19
- spec.metadata["changelog_uri"] = "https://github.com/gogrow-dev/mailcat/blob/main/CHANGELOG.md"
20
-
21
- # Specify which files should be added to the gem when it is released.
22
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
- spec.files = Dir.chdir(__dir__) do
24
- `git ls-files -z`.split("\x0").reject do |f|
25
- (File.expand_path(f) == __FILE__) ||
26
- f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
27
- end
28
- end
29
- spec.bindir = "exe"
30
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
- spec.require_paths = ["lib"]
32
-
33
- # Uncomment to register a new dependency of your gem
34
- spec.add_runtime_dependency "activesupport", ">= 6.0.0"
35
-
36
- # For more information and examples about making a new gem, check out our
37
- # guide at: https://bundler.io/guides/creating_gem.html
38
- end