README.md in tuktuk-0.6.0 vs README.md in tuktuk-0.6.1
- old
+ new
@@ -23,10 +23,25 @@
}
response, email = Tuktuk.deliver(message)
```
+HTML (multipart) emails are supported, of course.
+
+``` ruby
+
+message = {
+ :from => 'you@username.com',
+ :to => 'user@yoursite.com',
+ :body => 'Hello there',
+ :html_body => '<h1 style="color: red">Hello there</h1>',
+ :subject => 'Hiya in colours'
+}
+
+response, email = Tuktuk.deliver(message)
+```
+
The `response` is either a Net::SMTP::Response object, or a Bounce exception (HardBounce or SoftBounce, depending on the cause). `email` is a [mail](https://github.com/mikel/mail) object. So, to handle bounces you'd do:
``` ruby
[...]
@@ -37,12 +52,51 @@
else
puts 'Email delivered!'
end
```
-You can also call `Tuktuk.deliver!` (with a trailing `!`), in which case it will automatically raise an exception if the response was either a HardBounce or SoftBounce. This is useful when running in the background via Resque or Sidekiq, because it makes you aware of which emails are not getting through, and you can requeue those jobs to have them redelivered.
+You can also call `Tuktuk.deliver!` (with a trailing `!`), in which case it will automatically raise an exception if the response was either a `HardBounce` or a `SoftBounce`. This is useful when running in the background via Resque or Sidekiq, because it makes you aware of which emails are not getting through, and you can requeue those jobs to have them redelivered.
+Email options
+-------------
+
+Attachments are supported, as you'd expect.
+
+``` rb
+message = {
+ :from => 'john@lennon.com',
+ :to => 'paul@maccartney.com',
+ :subject => 'Question for you',
+ :body => 'How do you sleep?',
+ :reply_to => '<haha@foobar.com>',
+ :return_path => 'bounces@server.com',
+ :attachments => [ '/home/john/walrus.png' ]
+}
+```
+
+Attachments can be either a path to a file or a hash containing the file's name and content, like this:
+
+``` rb
+ message = {
+ ...
+ :attachments => [
+ { :filename => 'walrus.png', :content => File.read('/home/john/walrus.png') }
+ ]
+ }
+```
+
+These are the email headers Tuktuk is able to set for you. Just pass them as part of the hash and they'll be automatically set.
+
+```
+ :return_path => '<return-path@host.com>', # will actually set three headers, Return-Path, Bounces-To and Errors-To
+ :reply_to => '<reply@to.com>',
+ :in_reply_to => '<inreply@to.com>',
+ :list_unsubscribe => '<http://server.com/path>, <mailto:somewhere@server.com>',
+ :list_archive => '<http://server.com/list/archive>',
+ :list_id => '<mail-list.foobar.com>'
+```
+
Delivering multiple
-------------------
With Tuktuk, you can also deliver multiple messages at once. Depending on the `max_workers` config parameter, Tuktuk will either connect sequentially to the target domain's MX servers, or do it in parallel by spawning threads.
@@ -67,11 +121,11 @@
```
Options & DKIM
--------------
-Now, if you want to enable DKIM (and you should):
+Now, if you want to enable DKIM (and you _should_):
``` ruby
require 'tuktuk'
Tuktuk.options = {
@@ -102,10 +156,10 @@
:debug => false, # connects and delivers email to localhost, instead of real target server. CAUTION!
:dkim => { ... }
}
```
-You can set the `max_threads` option to `auto`, which will spawn the necessary threads to connect in paralell to all target MX servers when delivering multiple messages. When set to `0`, these batches will be delivered sequentially.
+You can set the `max_workers` option to `auto`, which will spawn the necessary threads to connect in paralell to all target MX servers when delivering multiple messages. When set to `0`, these batches will be delivered sequentially.
In other words, if you have three emails targeted to Gmail users and two for Hotmail users, using `auto` Tuktuk will spawn two threads and connect to both servers at once. Using `0` will have email deliveried to one host and then the other.
Using with Rails
----------------