smailer 0.5.1 → 0.5.2

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.
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Intro
4
4
 
5
- This project is a simple mailer for newsletters, which implements simple queue processing, basic campaign management and has some unsubscribe support.
5
+ This project is a simple mailer for newsletters, which implements simple queue processing, basic campaign management, [VERP support](http://en.wikipedia.org/wiki/Variable_envelope_return_path), bounce processing and auto-unsubscribe of invalid emails and aslo assists you in implementing unsubscribe links in the email messages.
6
6
 
7
7
  It is intended to be used within a Rails project. It has been tested with Rails 3.0.x, Rails 3.1.0 and Rails 2.3.5.
8
8
 
@@ -120,11 +120,41 @@ This task can be executed via `RAILS_ENV=production bundle exec rake smailer:sen
120
120
 
121
121
  Notice that we pass a `:return_path_domain` option to `Send.execute`. This domain will be used to construct a dynamic `Return-Path:` address, which you could later use in order to process bounced mails and connect the bounce with a concrete mail campaign and sender's email address. The generated return path will have the following format: `"bounces-SOMEKEY@bounces.mydomain.com"`, where `SOMEKEY` will be the same as the `key` field in the corresponding `FinishedMail` record and will uniquely identify this record, and `bounces.mydomain.com` is what you passed to `:return_path_domain`.
122
122
 
123
- Dynamic return path is generated only when `:return_path_domain` is specified and `:verp` is not false. If you omit the `:verp` option and just pass `:return_path_domain`, `Send.execute` will still use VERP and generate dynamic return path addresses.
123
+ Dynamic return path is generated only when `:return_path_domain` is specified and `:verp` is not false. If you omit the `:verp` option and just pass `:return_path_domain`, `Send.execute` will still use [VERP](http://en.wikipedia.org/wiki/Variable_envelope_return_path) and generate dynamic return path addresses.
124
+
125
+ ### Processing bounces and auto-unsubscribing bad emails
126
+
127
+ If you use the [VERP support](http://en.wikipedia.org/wiki/Variable_envelope_return_path) Smailer provides when sending your messages, you can easily implement auto-unsubscribe for invalid email addressess or for addresses which bounce too much.
128
+
129
+ This can be done via a simple cron task, which runs daily (or whatever) on your servers.
130
+
131
+ Suppose you manage your site's newsletter subscriptions via a `Subscription` model, which has two boolean flags -- `subscribed` and `confirmed` and also an `email` field. You could implement a simple Rake task to be run via a cron daemon this way:
132
+
133
+ task :process_bounces => :environment do
134
+ subscribed_checker = lambda do |recipient|
135
+ Subscription.confirmed.subscribed.where(:email => recipient).first.present?
136
+ end
137
+
138
+ Smailer::Tasks::ProcessBounces.execute({
139
+ :server => 'bounces.mydomain.com',
140
+ :username => 'no-reply@bounces.mydomain.com',
141
+ :password => 'mailbox-password',
142
+ :subscribed_checker => subscribed_checker,
143
+ }) do |unsubscribe_details|
144
+ subscription = Subscription.confirmed.subscribed.where(:email => unsubscribe_details[:recipient]).first
145
+
146
+ if subscription
147
+ subscription.subscribed = false
148
+ subscription.unsubscribe_reason = 'Automatic, due to bounces'
149
+ subscription.save!
150
+ end
151
+ end
152
+ end
153
+
154
+ For more info and also if you'd like to adjust the unsubscribe rules, take a look at the `ProcessBounces.execute` method and its options. It's located in `lib/smailer/tasks/process_bounces.rb`. A few extra options are available, such as `:logger` callbacks (which defaults to `puts`), default action for unprocessed bounces, etc.
124
155
 
125
156
  ## TODO
126
157
 
127
- * Bounce processing
128
158
  * Tests, tests, tests
129
159
 
130
160
  ## Contribution
@@ -154,7 +154,11 @@ module Smailer
154
154
 
155
155
  key = to.strip.split('@').first[Smailer::BOUNCES_PREFIX.size..-1]
156
156
 
157
- @@keys_messages[key] ||= Smailer::Models::FinishedMail.where(:key => key).first
157
+ @@keys_messages[key] ||= Smailer::Compatibility.rails_3?
158
+ Smailer::Models::FinishedMail.where(:key => key).first
159
+ else
160
+ Smailer::Models::FinishedMail.first(:conditions => {:key => key})
161
+ end
158
162
  end
159
163
  end
160
164
  end
@@ -1,7 +1,7 @@
1
1
  module Smailer
2
2
  MAJOR = 0
3
3
  MINOR = 5
4
- PATCH = 1
4
+ PATCH = 2
5
5
 
6
6
  VERSION = [MAJOR, MINOR, PATCH].join('.')
7
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smailer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 1
10
- version: 0.5.1
9
+ - 2
10
+ version: 0.5.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dimitar Dimitrov