Description
A gem that makes it easy to automatically unsubscribe from emails in Rails.
๐ญ Unsubscribe alternatives and similar gems
Based on the "Email" category.
Alternatively, view unsubscribe alternatives based on common mentions on social networks and blogs.
-
Truemail
๐ Configurable framework agnostic plain Ruby ๐จ email validator/verifier. Verify email via Regex, DNS, SMTP and even more. Be sure that email address valid and exists. -
MailForm
Send e-mail straight from forms in Rails with I18n, validations, attachments and request information. -
Markerb
DISCONTINUED. Allows you to render multipart e-mails from a single template written in Markdown. -
ActionMailer Balancer
A Ruby gem to send your ActionMailer mail through one of several delivery methods, selected by weight.
SaaSHub - Software Alternatives and Reviews
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of ๐ญ Unsubscribe or a related project?
README
๐ญ Unsubscribe
Automatically unsubscribe from emails in Rails.
[Demo](./docs/demo.gif)
๐ Installation
Add this line to your application's Gemfile:
gem 'unsubscribe'
And then execute:
$ bundle
Or install it yourself as:
$ gem install unsubscribe
Then run the installation commands:
rails g unsubscribe:install
rails unsubscribe:install:migrations
rails db:migrate
๐ Usage
Unsubscribe::Owner
- Add
include Unsubscribe::Owner
to aModel
. TheModel
must have anemail
column.
class User < ApplicationRecord
include Unsubscribe::Owner
end
Available Methods
User.first.mailer_subscriptions
# => #<ActiveRecord::Associations::CollectionProxy [#<Unsubscribe::MailerSubscription>, #<Unsubscribe::MailerSubscription>] >
User.first.subscribed_to_mailer? "MarketingMailer"
# => true/false
User.first.to_sgid_for_mailer_subscription
# => #<SignedGlobalID:123 ...>
Unsubscribe::Mailer
- Add
include Unsubscribe::Mailer
to aMailer
. - Optionally call
unsubscribe_settings
to set aname
anddescription
. This will be used in the unsubscribe page. - Set
mail to:
to@recipient.email
. The@recipient
is an instance of whatever Classinclude Unsubscribe::Owner
was added to.
class MarketingMailer < ApplicationMailer
include Unsubscribe::Mailer
unsubscribe_settings name: "Marketing Emails", description: "Updates on promotions and sales."
def promotion
mail to: @recipient.email
end
end
- Call the
Mailer
with arecipient
parameter.
MarketingMailer.with(
recipient: User.first
).promotion.deliver_now
Available Methods
Unsubscribe::MailerSubscription.first.action
# => "Unsubscribe from"/"Subscribe to"
Unsubscribe::MailerSubscription.first.call_to_action
# => "Unsubscribe from Marketing Emails"/"Subscribe to Marketing Emails"
Unsubscribe::MailerSubscription.first.description
# => "Updates on promotions and sales."
Unsubscribe::MailerSubscription.first.name
# => "Marketing Emails"
Unsubscribe Link
- Add the
@unsubscribe_url
link to theMailer
.
<%= link_to "Unsubscribe", @unsubscribe_url %>
โ๏ธ Customize Templates
Run rails g unsubscribe:views
if you want to modify the existing templates.
๐ I18n
The language used for Unsubscribe::MailerSubscription#action
can be translated.
# config/locales/en.yml
en:
unsubscribe:
action:
subscribe: "Subscribe to"
unsubscribe: "Unsubscribe from"
๐ Contributing
If you'd like to open a PR please make sure the following things pass:
bin/rails test
bundle exec standardrb
๐ License
The gem is available as open source under the terms of the MIT License.
*Note that all licence references and agreements mentioned in the ๐ญ Unsubscribe README section above
are relevant to that project's source code only.