Permalink
Browse files

Sending speed: docs and refactoring

  • Loading branch information...
1 parent 9e24226 commit 8457256ff1f4d21ba5a5b444dc857a5605cfa01c @macuk committed Apr 13, 2012
Showing with 20 additions and 6 deletions.
  1. +10 −2 README.md
  2. +1 −0 lib/mailing.rb
  3. +3 −0 lib/mailing/delay.rb
  4. +2 −2 lib/mailing/mailing.rb
  5. +3 −1 lib/mailing/sender.rb
  6. +1 −1 mailing.gemspec
View
@@ -1,6 +1,6 @@
# Mailing
-Tool for sending fast mailings
+Tool for sending fast mailings in one SMTP connection.
## Installation
@@ -16,6 +16,11 @@ Or install it yourself as:
$ gem install mailing
+## Sending speed
+
+Default sending speed is low and set to ~ 120 mails per minute.
+You can change that value by setting the delay parameter in sender.
+
## Step by step usage
require 'mailing'
@@ -32,6 +37,7 @@ Or install it yourself as:
# create sender with channel, envelope_from and logger
logger = Logger.new('/tmp/mailing.log')
sender = Mailing::Sender.new(channel, 'sender@domain.com', logger)
+ sender.delay = 0.1 # ~ 600 mails per minute
# create mailing with from, subject, body, recipients
mailing = Mailing::Mailing.new('from@domain.com', 'Subject', 'Body')
@@ -52,7 +58,9 @@ Or install it yourself as:
:port => 25,
:domain => 'localhost.localdomain'
}
- mailing.send_by_smtp(config, 'sender@domain.com')
+ # send with config and envelope_from set to sender@domain.com
+ # without logging and with 0.2 delay (~ 300 mails per minute)
+ mailing.send_by_smtp(config, 'sender@domain.com', nil, 0.2)
## Rails usage
View
@@ -1,4 +1,5 @@
require 'mailing/version'
+require 'mailing/delay'
require 'mailing/mailing'
require 'mailing/sender'
require 'mailing/smtp_channel'
View
@@ -0,0 +1,3 @@
+module Mailing
+ DELAY = 0.5
+end
View
@@ -13,9 +13,9 @@ def send(sender)
sender.send(self)
end
- def send_by_smtp(config, envelope_from, logger=nil)
+ def send_by_smtp(config, envelope_from, logger=nil, delay=DELAY)
channel = SmtpChannel.new(config)
- sender = Sender.new(channel, envelope_from, logger)
+ sender = Sender.new(channel, envelope_from, logger, delay)
send(sender)
end
View
@@ -1,8 +1,10 @@
+require 'mailing/delay'
+
module Mailing
class Sender
attr_accessor :channel, :envelope_from, :logger, :delay
- def initialize(channel, envelope_from, logger=nil, delay=0.5)
+ def initialize(channel, envelope_from, logger=nil, delay=DELAY)
@channel = channel
@envelope_from = envelope_from
@logger = logger
View
@@ -4,7 +4,7 @@ require File.expand_path('../lib/mailing/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Piotr Macuk"]
gem.email = ["piotr@macuk.pl"]
- gem.description = %q{Tool for sending fast mailings}
+ gem.description = %q{Tool for sending fast mailings in one SMTP connection}
gem.summary = %q{Fast mailings}
gem.homepage = "https://github.com/macuk/mailing"

0 comments on commit 8457256

Please sign in to comment.