pony 1.10 → 1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21b0731fb0237480bcebbaabdb5a16f2cd912ac8
4
- data.tar.gz: 51429c927817896031f8505403189ed34bf272bb
3
+ metadata.gz: 3174f77ea35e6999224137e7bfa6267bdada8642
4
+ data.tar.gz: eca13df1efe9e87982f83f09cbf12df3022db9cf
5
5
  SHA512:
6
- metadata.gz: 4e080bca7fc9a958ca2bcb9fa19c24b67832c9e13c42c7cb42edd3c884735a4801495e79693fed386672aa1e96624cb238146cdce7bf67cd8dd3cb62a0501109
7
- data.tar.gz: d74c23bf55d5b4429de41a321b2d6ca99378d711f64cb9b5108d0536eb700ec2ba426e5cd13102fcdfbc43612b301669c82a599f2b750076c8d50a15220e874b
6
+ metadata.gz: d1945679fe5266a6973539300fabb181eea9d8abc69ec4bad21841d0df52fc244ef430c73a09a7c8952a0b1c0c9591f13724216c4bfeabd5266b4fbff3b14c76
7
+ data.tar.gz: 7d3f7bcd9ef86f858271d850f364fb8837ec861a16b2214941b89df9d6d2531e53c4da569e43ce1bc48a86da9f2337d7a1b10f75e9ca472eab70ba9a3c60f89f
@@ -0,0 +1,274 @@
1
+ # Pony, the express way to send email in Ruby #
2
+
3
+ ## Overview ##
4
+
5
+ Ruby no longer has to be jealous of PHP's mail() function, which can send an email in a single command.
6
+
7
+ Pony.mail(:to => 'you@example.com', :from => 'me@example.com', :subject => 'hi', :body => 'Hello there.')
8
+ Pony.mail(:to => 'you@example.com', :html_body => '<h1>Hello there!</h1>', :body => "In case you can't read html, Hello there.")
9
+ Pony.mail(:to => 'you@example.com', :cc => 'him@example.com', :from => 'me@example.com', :subject => 'hi', :body => 'Howsit!')
10
+
11
+ Any option key may be omitted except for ```:to```. See List Of Options section for the complete list.
12
+
13
+ ## Transport ##
14
+
15
+ Pony uses ```/usr/sbin/sendmail``` to send mail if it is available, otherwise it uses SMTP to localhost.
16
+
17
+ This can be over-ridden if you specify a via option:
18
+
19
+ Pony.mail(:to => 'you@example.com', :via => :smtp) # sends via SMTP
20
+ Pony.mail(:to => 'you@example.com', :via => :sendmail) # sends via sendmail
21
+
22
+ You can also specify options for SMTP:
23
+
24
+ Pony.mail({
25
+ :to => 'you@example.com',
26
+ :via => :smtp,
27
+ :via_options => {
28
+ :address => 'smtp.yourserver.com',
29
+ :port => '25',
30
+ :user_name => 'user',
31
+ :password => 'password',
32
+ :authentication => :plain, # :plain, :login, :cram_md5, no auth by default
33
+ :domain => "localhost.localdomain" # the HELO domain provided by the client to the server
34
+ }
35
+ })
36
+
37
+ Gmail example (with TLS/SSL)
38
+
39
+ Pony.mail({
40
+ :to => 'you@example.com',
41
+ :via => :smtp,
42
+ :via_options => {
43
+ :address => 'smtp.gmail.com',
44
+ :port => '587',
45
+ :enable_starttls_auto => true,
46
+ :user_name => 'user',
47
+ :password => 'password',
48
+ :authentication => :plain, # :plain, :login, :cram_md5, no auth by default
49
+ :domain => "localhost.localdomain" # the HELO domain provided by the client to the server
50
+ }
51
+ })
52
+
53
+ And options for Sendmail:
54
+
55
+ Pony.mail({
56
+ :to => 'you@example.com',
57
+ :via => :sendmail,
58
+ :via_options => {
59
+ :location => '/path/to/sendmail', # defaults to 'which sendmail' or '/usr/sbin/sendmail' if 'which' fails
60
+ :arguments => '-t' # -t and -i are the defaults
61
+ }
62
+ })
63
+
64
+ If you're using ssmtp, set ```:arguments => ''```.
65
+
66
+ ## Attachments ##
67
+
68
+ You can attach a file or two with the :attachments option:
69
+
70
+ Pony.mail(..., :attachments => {"foo.zip" => File.read("path/to/foo.zip"), "hello.txt" => "hello!"})
71
+
72
+ Note: An attachment's mime-type is set based on the filename (as dictated by the ruby gem mime-types). So 'foo.pdf' has a mime-type of 'application/pdf'
73
+
74
+ ## Custom Headers ##
75
+
76
+ Pony allows you to specify custom mail headers
77
+
78
+ Pony.mail(
79
+ :to => 'me@example.com',
80
+ :headers => { "List-ID" => "...", "X-My-Custom-Header" => "what a cool custom header" }
81
+ )
82
+
83
+ Add additional options for headers in each part of letter (text, html)
84
+
85
+ Pony.mail(
86
+ :body => 'test',
87
+ :html_body => 'What do you know, Joe?',
88
+ :attachments => {"foo.txt" => "content of foo.txt"},
89
+ :body_part_header => { content_disposition: "inline" }
90
+ )
91
+
92
+ This will add option ```'Content-Disposition: inline'``` for text part header of letter.
93
+
94
+ Also you can add additional options for html part of latter, e.g.:
95
+
96
+ :html_body_part_header => { content_disposition: "inline" }
97
+
98
+
99
+ ## List Of Options ##
100
+
101
+ You can get a list of options from Pony directly:
102
+
103
+ Pony.permissable_options
104
+
105
+ Options passed pretty much directly to Mail
106
+
107
+ attachments # see Attachments section
108
+ bcc
109
+ body # the plain text body
110
+ body_part_header # see Custom headers section
111
+ cc
112
+ charset # In case you need to send in utf-8 or similar
113
+ content_type
114
+ from
115
+ headers # see Custom headers section
116
+ html_body # for sending html-formatted email
117
+ html_body_part_header # see Custom headers section
118
+ message_id
119
+ reply_to
120
+ sender # Sets "envelope from" (and the Sender header)
121
+ smtp_envelope_to
122
+ subject
123
+ text_part_charset # for multipart messages, set the charset of the text part
124
+ to
125
+
126
+ Other options
127
+ via # :smtp or :sendmail, see Transport section
128
+ via_options # specify transport options, see Transport section
129
+
130
+ ### Default Options ###
131
+
132
+ Default options can be set so that they don't have to be repeated. The default options you set will be overriden by any options you pass in to Pony.mail()
133
+
134
+ Pony.options = { :from => 'noreply@example.com', :via => :smtp, :via_options => { :host => 'smtp.yourserver.com' } }
135
+ Pony.mail(:to => 'foo@bar') # Sends mail to foo@bar from noreply@example.com using smtp
136
+ Pony.mail(:from => 'pony@example.com', :to => 'foo@bar') # Sends mail to foo@bar from pony@example.com using smtp
137
+
138
+
139
+ ### Override Options ###
140
+
141
+ Override options can be set so that the override value is always be used, even if a different value is passed in to Pony.options() or Pony.mail(). This can be used to configure a development or staging environment.
142
+
143
+ Pony.override_options = { :to => 'test@example.com' }
144
+ Pony.mail(:to => 'foo@bar') # Sends mail to test@example.com instead of foo@bar
145
+
146
+ ## Testing/Debugging Aids ##
147
+
148
+ [![Build Status](https://travis-ci.org/benprew/pony.svg?branch=master)](https://travis-ci.org/benprew/pony)
149
+
150
+ ### Subject prefix ###
151
+
152
+ Prepends a string to the subject line. This is used to identify email sent from a specific environment.
153
+
154
+ Pony.subject_prefix('Prefix:')
155
+
156
+ ### Append options to body ###
157
+
158
+ Append the options passd into Pony.mail to the body of the email. Useful for debugging.
159
+
160
+ Pony.append_inputs
161
+
162
+ ## Help ##
163
+
164
+ If you need help using Pony, or it looks like you've found a bug,
165
+ email ponyrb@googlegroups.com. The full forum is
166
+ https://groups.google.com/forum/#!forum/ponyrb
167
+
168
+ ### Meta ###
169
+
170
+ * Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php)
171
+ * [Homepage](http://github.com/benprew/pony)
172
+ * Mailing List: ponyrb@googlegroups.com
173
+
174
+ ## Authors ##
175
+ * Adam Wiggins [@adamwiggins](https://github.com/adamwiggins)
176
+ * Ben Prew [@benprew](https://github.com/benprew)
177
+ * Cameron Matheson [@cmatheson](https://github.com/cmatheson)
178
+ * Carl Hörberg [@carlhoerberg](https://github.com/carlhoerberg)
179
+ * Daniel Lopes [@danielvlopes](https://github.com/danielvlopes)
180
+ * Doug Hammond [@dslh](https://github.com/dslh)
181
+ * Hiroshi Saito [@hiroshi](https://github.com/hiroshi)
182
+ * Kalin Harvey
183
+ * MIKAMI Yoshiyuki [@yoshuki](https://github.com/yoshuki)
184
+ * Mathieu Martin [@webmat](https://github.com/webmat)
185
+ * Michael Durrant [@durrantm](https://github.com/durrantm)
186
+ * Neil Middleton [@neilmiddleton](https://github.com/neilmiddleton)
187
+ * Neil Mock [@neilmock](https://github.com/neilmock)
188
+ * Nickolas Means [@nmeans](https://github.com/nmeans)
189
+ * Othmane Benkirane [@anaothmane](https://github.com/anaothmane)
190
+ * Rich Meyers [@richmeyers](https://github.com/richmeyers)
191
+ * Roman Franko [@roman-franko](https://github.com/roman-franko)
192
+ * Ryan Malecky [@rmalecky](https://github.com/rmalecky)
193
+ * Seamus Abshere [@seamusabshere](https://github.com/seamusabshere)
194
+ * Stephen Celis [@stephencelis](https://github.com/stephencelis)
195
+ * arunthampi [@arunthampi](https://github.com/arunthampi)
196
+ * rick [@rick](https://github.com/rick)
197
+ * rohit [@rohit](https://github.com/rohit)
198
+
199
+ ## Changelog ##
200
+
201
+ #### 1.11 ####
202
+ * Improved handling of mails with both text and html bodies and attachments
203
+
204
+ #### 1.10 ####
205
+ * Add ```subject_prefix```, ```append_options``` and ```override_options```
206
+
207
+ #### 1.9 ####
208
+ * Allow options to be queried from the gem
209
+
210
+ #### 1.8 ####
211
+ * Add additional options for headers in each part of letter
212
+
213
+ #### 1.7 ####
214
+ * Better default content_type with attachments
215
+
216
+ #### 1.6 ####
217
+ * Unknown options are passed directly to mail to handle. Remove deprecated syntax
218
+
219
+ #### 1.5.1 ####
220
+ * Loosen mail dependency to >= 2.0 instead of > 2.0
221
+
222
+ #### 1.5 ####
223
+ * Specify content-id of attachments as filename@hostname
224
+
225
+ #### 1.4.1 ####
226
+ * Update gemfile
227
+
228
+ #### 1.4 ####
229
+ * Updated docs
230
+
231
+ #### 1.3 ####
232
+ * Add new option ```:text_part_charset```, which allows you to specify the charset for the text portion
233
+
234
+ #### 1.2 ####
235
+ * Remove limitations on :via, and let mail handle it (this means you can say things like :via => test)
236
+ * Add reply-to option and a bundler file
237
+
238
+ #### 1.1 ####
239
+ * Add default options
240
+
241
+ #### 1.0 ####
242
+ * Convert to using Mail as the mail-generation backend, instead of TMail
243
+
244
+ #### 0.9.1 ####
245
+ * provide the ability to set custom mail headers with something like:
246
+ Pony.mail(:headers => {"List-ID" => "..."})
247
+ * provide the ability to set the Message-Id from Pony.mail
248
+
249
+ #### 0.9 ####
250
+ * merge in kalin's fixes to use tmail.destinations instead of trying to parse tmail.to, tmail.cc and tmail.bcc. New specs to test functionality
251
+
252
+ #### 0.8 ####
253
+ * Fix bug that was allowing nil :bcc and :cc options to be passed to smtp
254
+
255
+ #### 0.7 ####
256
+ * Pass :cc and :bcc options to sendmail appropriately
257
+
258
+ #### 0.6 ####
259
+ * Add :bcc capability
260
+ * Add :charset capability
261
+ * Add complete list of options to readme
262
+ * fix bug: readme examples
263
+
264
+ #### 0.5 ####
265
+ * default location of sendmail to /usr/sbin/sendmail if sendmail not in path
266
+ * fix bug: README not showing password option (listed as pass)
267
+
268
+ #### 0.4.1 ####
269
+ * Add :cc capability
270
+ * fix bug: resolve body not displaying when attachments sent
271
+
272
+ #### 0.4 ####
273
+ * Implemented file attachments option
274
+ * use TLS if :tls => true
data/Rakefile CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'rake'
2
2
  require 'rspec/core/rake_task'
3
+ require 'json'
4
+ require 'uri'
3
5
 
4
6
  desc "Run all specs"
5
7
  RSpec::Core::RakeTask.new(:test)
@@ -27,7 +29,15 @@ task :uninstall => [ :clean ] do
27
29
  end
28
30
 
29
31
  task :authors do
30
- sh %{git log |grep Author |cut -f 1 -d'<' |cut -f2 -d':' |sort -u}
32
+ token = `cat ~/.github_token`.chomp
33
+ authors = `git log |grep Author |cut -f 1 -d'<' |cut -f2 -d':' |sort -u`
34
+ authors.split(/\n/).each do |a|
35
+ print "* #{a} "
36
+ ainfo = JSON.parse `curl -u #{token}:x-oauth-basic --silent https://api.github.com/search/users?q=#{URI.encode a}`
37
+ puts ainfo unless ainfo['total_count']
38
+ (puts; next) unless ainfo && ainfo['total_count'] > 0
39
+ puts "[@#{ainfo['items'][0]['login']}](#{ainfo['items'][0]['html_url']})"
40
+ end
31
41
  end
32
42
 
33
43
  CLEAN.include [ 'pkg', '*.gem', '.config' ]
@@ -222,29 +222,30 @@ module Pony
222
222
  m.send(k, v)
223
223
  end
224
224
 
225
- if options[:html_body]
226
- html_part do
227
- content_type 'text/html; charset=UTF-8'
228
- body options[:html_body]
229
- if options[:html_body_part_header] && options[:html_body_part_header].is_a?(Hash)
230
- options[:html_body_part_header].each do |k,v|
231
- header[k] = v
232
- end
233
- end
225
+ # Automatic handling of multipart messages in the underlying
226
+ # mail library works pretty well for the most part, but in
227
+ # the case where we have attachments AND text AND html bodies
228
+ # we need to explicitly define a second multipart/alternative
229
+ # boundary to encapsulate the body-parts within the
230
+ # multipart/mixed boundary that will be created automatically.
231
+ if options[:attachments] && options[:html_body] && options[:body]
232
+ part(:content_type => 'multipart/alternative') do |p|
233
+ p.html_part = Pony.build_html_part(options)
234
+ p.text_part = Pony.build_text_part(options)
235
+ end
236
+
237
+ # Otherwise if there is more than one part we still need to
238
+ # ensure that they are all declared to be separate.
239
+ elsif options[:html_body] || options[:attachments]
240
+ if options[:html_body]
241
+ m.html_part = Pony.build_html_part(options)
234
242
  end
235
- end
236
243
 
237
- # If we're using attachments, the body needs to be a separate
238
- # part. If not, we can just set the body directly.
239
- if options[:body] && (options[:html_body] || options[:attachments])
240
- text_part do
241
- body options[:body]
242
- if options[:body_part_header] && options[:body_part_header].is_a?(Hash)
243
- options[:body_part_header].each do |k,v|
244
- header[k] = v
245
- end
246
- end
244
+ if options[:body]
245
+ m.text_part = Pony.build_text_part(options)
247
246
  end
247
+
248
+ # If all we have is a text body, we don't need to worry about parts.
248
249
  elsif options[:body]
249
250
  body options[:body]
250
251
  end
@@ -267,6 +268,30 @@ module Pony
267
268
  mail
268
269
  end
269
270
 
271
+ def self.build_html_part(options)
272
+ Mail::Part.new(:content_type => 'text/html;charset=UTF-8') do
273
+ content_transfer_encoding 'quoted-printable'
274
+ body Mail::Encodings::QuotedPrintable.encode(options[:html_body])
275
+ if options[:html_body_part_header] && options[:html_body_part_header].is_a?(Hash)
276
+ options[:html_body_part_header].each do |k,v|
277
+ header[k] = v
278
+ end
279
+ end
280
+ end
281
+ end
282
+
283
+ def self.build_text_part(options)
284
+ Mail::Part.new(:content_type => 'text/plain') do
285
+ content_type options[:charset] if options[:charset]
286
+ body options[:body]
287
+ if options[:body_part_header] && options[:body_part_header].is_a?(Hash)
288
+ options[:body_part_header].each do |k,v|
289
+ header[k] = v
290
+ end
291
+ end
292
+ end
293
+ end
294
+
270
295
  def self.set_content_type(mail, user_content_type)
271
296
  params = mail.content_type_parameters || {}
272
297
  content_type = case
@@ -288,6 +313,8 @@ module Pony
288
313
 
289
314
  def self.add_attachments(mail, attachments)
290
315
  attachments.each do |name, body|
316
+ name = name.gsub /\s+/, ' '
317
+
291
318
  # mime-types wants to send these as "quoted-printable"
292
319
  if name =~ /\.xlsx$/
293
320
  mail.attachments[name] = {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'pony'
5
- s.version = "1.10"
5
+ s.version = "1.11"
6
6
 
7
7
  s.summary = "Send email in one command: Pony.mail(:to => 'someone@example.com', :body => 'hello')"
8
8
  s.description = s.summary
@@ -11,9 +11,10 @@ Gem::Specification.new do |s|
11
11
  s.homepage = 'http://github.com/benprew/pony'
12
12
  s.license = 'MIT'
13
13
 
14
- s.files = ["README.rdoc", "Rakefile", "pony.gemspec" ] + Dir.glob("{lib,spec}/**/*")
14
+ s.files = ["README.md", "Rakefile", "pony.gemspec" ] + Dir.glob("{lib,spec}/**/*")
15
15
  s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
16
16
  s.require_paths = ["lib"]
17
17
  s.add_runtime_dependency 'mail', '>= 2.0'
18
18
  s.add_development_dependency "rspec", ">= 2.14"
19
+ s.add_development_dependency "rake", ">= 10"
19
20
  end
@@ -310,11 +310,13 @@ describe Pony do
310
310
  )
311
311
  end
312
312
 
313
- it { expect(mail.parts.length).to eq 3 }
313
+ it { expect(mail.parts.length).to eq 2 }
314
+ it { expect(mail.parts[0].parts.length).to eq 2 }
314
315
  it { expect(mail.content_type.to_s).to include( 'multipart/mixed' ) }
315
- it { expect(mail.parts[0].to_s).to include( 'Content-Type: text/html' ) }
316
+ it { expect(mail.parts[0].content_type.to_s).to include( 'multipart/alternative' ) }
317
+ it { expect(mail.parts[0].parts[0].to_s).to include( 'Content-Type: text/html' ) }
318
+ it { expect(mail.parts[0].parts[1].to_s).to include( 'Content-Type: text/plain' ) }
316
319
  it { expect(mail.parts[1].to_s).to include( 'Content-Type: text/plain' ) }
317
- it { expect(mail.parts[2].to_s).to include( 'Content-Type: text/plain' ) }
318
320
  end
319
321
  end
320
322
 
@@ -329,8 +331,8 @@ describe Pony do
329
331
  )
330
332
  end
331
333
 
332
- it { expect(mail.parts[0].to_s).to include( 'inline' ) }
333
- it { expect(mail.parts[1].to_s).to include( 'inline' ) }
334
+ it { expect(mail.parts[0].parts[0].to_s).to include( 'inline' ) }
335
+ it { expect(mail.parts[0].parts[1].to_s).to include( 'inline' ) }
334
336
 
335
337
  context "when parts aren't present" do
336
338
  subject(:mail) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pony
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.10'
4
+ version: '1.11'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Wiggins
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-10 00:00:00.000000000 Z
12
+ date: 2014-09-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mail
@@ -39,6 +39,20 @@ dependencies:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '2.14'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '10'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '10'
42
56
  description: 'Send email in one command: Pony.mail(:to => ''someone@example.com'',
43
57
  :body => ''hello'')'
44
58
  email: ben@throwingbones.com
@@ -46,7 +60,7 @@ executables: []
46
60
  extensions: []
47
61
  extra_rdoc_files: []
48
62
  files:
49
- - README.rdoc
63
+ - README.md
50
64
  - Rakefile
51
65
  - lib/pony.rb
52
66
  - pony.gemspec
@@ -1,276 +0,0 @@
1
- = Pony, the express way to send email in Ruby
2
-
3
- == Overview
4
-
5
- Ruby no longer has to be jealous of PHP's mail() function, which can send an email in a single command.
6
-
7
- Pony.mail(:to => 'you@example.com', :from => 'me@example.com', :subject => 'hi', :body => 'Hello there.')
8
- Pony.mail(:to => 'you@example.com', :html_body => '<h1>Hello there!</h1>', :body => "In case you can't read html, Hello there.")
9
- Pony.mail(:to => 'you@example.com', :cc => 'him@example.com', :from => 'me@example.com', :subject => 'hi', :body => 'Howsit!')
10
-
11
- Any option key may be omitted except for :to. For a complete list of options, see List Of Options section below.
12
-
13
-
14
- == Transport
15
-
16
- Pony uses /usr/sbin/sendmail to send mail if it is available, otherwise it uses SMTP to localhost.
17
-
18
- This can be over-ridden if you specify a via option:
19
-
20
- Pony.mail(:to => 'you@example.com', :via => :smtp) # sends via SMTP
21
-
22
- Pony.mail(:to => 'you@example.com', :via => :sendmail) # sends via sendmail
23
-
24
- You can also specify options for SMTP:
25
-
26
- Pony.mail({
27
- :to => 'you@example.com',
28
- :via => :smtp,
29
- :via_options => {
30
- :address => 'smtp.yourserver.com',
31
- :port => '25',
32
- :user_name => 'user',
33
- :password => 'password',
34
- :authentication => :plain, # :plain, :login, :cram_md5, no auth by default
35
- :domain => "localhost.localdomain" # the HELO domain provided by the client to the server
36
- }
37
- })
38
-
39
- Gmail example (with TLS/SSL)
40
-
41
- Pony.mail({
42
- :to => 'you@example.com',
43
- :via => :smtp,
44
- :via_options => {
45
- :address => 'smtp.gmail.com',
46
- :port => '587',
47
- :enable_starttls_auto => true,
48
- :user_name => 'user',
49
- :password => 'password',
50
- :authentication => :plain, # :plain, :login, :cram_md5, no auth by default
51
- :domain => "localhost.localdomain" # the HELO domain provided by the client to the server
52
- }
53
- })
54
-
55
- And options for Sendmail:
56
-
57
- Pony.mail({
58
- :to => 'you@example.com',
59
- :via => :sendmail,
60
- :via_options => {
61
- :location => '/path/to/sendmail', # defaults to 'which sendmail' or '/usr/sbin/sendmail' if 'which' fails
62
- :arguments => '-t' # -t and -i are the defaults
63
- }
64
- })
65
-
66
- If you're using <tt>ssmtp</tt>, set <tt>:arguments => ''</tt>.
67
-
68
- == Attachments
69
-
70
- You can attach a file or two with the :attachments option:
71
-
72
- Pony.mail(..., :attachments => {"foo.zip" => File.read("path/to/foo.zip"), "hello.txt" => "hello!"})
73
-
74
- Note: An attachment's mime-type is set based on the filename (as dictated by the ruby gem mime-types). So 'foo.pdf' has a mime-type of 'application/pdf'
75
-
76
- == Custom Headers
77
-
78
- Pony allows you to specify custom mail headers
79
- Pony.mail(
80
- :to => 'me@example.com',
81
- :headers => { "List-ID" => "...", "X-My-Custom-Header" => "what a cool custom header" }
82
- )
83
-
84
- Add additional options for headers in each part of letter (text, html)
85
- Pony.mail(
86
- :body => 'test',
87
- :html_body => 'What do you know, Joe?',
88
- :attachments => {"foo.txt" => "content of foo.txt"},
89
- :body_part_header => { content_disposition: "inline" }
90
- )
91
-
92
- This will add option 'Content-Disposition: inline' for text part header of letter.
93
-
94
- Also you can add additional options for html part of latter, e.g.:
95
- :html_body_part_header => { content_disposition: "inline" }
96
-
97
-
98
- == List Of Options
99
-
100
- You can get a list of options from Pony directly:
101
-
102
- Pony.permissable_options
103
-
104
- Options passed pretty much directly to Mail
105
-
106
- to
107
- cc
108
- bcc
109
- from
110
- body # the plain text body
111
- html_body # for sending html-formatted email
112
- subject
113
- content_type
114
- charset # In case you need to send in utf-8 or similar
115
- text_part_charset # for multipart messages, set the charset of the text part
116
- attachments # see Attachments section above
117
- headers # see Custom headers section above
118
- body_part_header # see Custom headers section above
119
- html_body_part_header # see Custom headers section above
120
- message_id
121
- sender # Sets "envelope from" (and the Sender header)
122
- reply_to
123
- smtp_envelope_to
124
-
125
- Other options
126
- via # :smtp or :sendmail, see Transport section above
127
- via_options # specify transport options, see Transport section above
128
-
129
- == Set default options
130
-
131
- Default options can be set so that they don't have to be repeated. The default options you set will be overriden by any options you pass in to Pony.mail()
132
-
133
- Pony.options = { :from => 'noreply@example.com', :via => :smtp, :via_options => { :host => 'smtp.yourserver.com' } }
134
- Pony.mail(:to => 'foo@bar') # Sends mail to foo@bar from noreply@example.com using smtp
135
- Pony.mail(:from => 'pony@example.com', :to => 'foo@bar') # Sends mail to foo@bar from pony@example.com using smtp
136
-
137
-
138
- == Set override options
139
-
140
- Override options can be set so that the override value is always be used, even if a different value is passed in to Pony.options() or Pony.mail(). This can be used to configure a development or staging environment.
141
-
142
- Pony.override_options = { :to => 'test@example.com' }
143
- Pony.mail(:to => 'foo@bar') # Sends mail to test@example.com instead of foo@bar
144
-
145
- == Set subject prefix
146
-
147
- Prepends a string to the subject line. This is used to identify email sent from a specific environment.
148
-
149
- Pony.subject_prefix('Prefix:')
150
-
151
- == Append options to body
152
-
153
- Append the options passd into Pony.mail to the body of the email. Useful for debugging.
154
-
155
- Pony.append_inputs
156
-
157
- == Help
158
-
159
- If you need help using Pony, or it looks like you've found a bug,
160
- email ponyrb@googlegroups.com. The full forum is
161
- https://groups.google.com/forum/#!forum/ponyrb
162
-
163
- == External Dependencies
164
-
165
- mail > 2.0
166
-
167
- Note: these requirements are specified in the gemspec as well. Also, you may need smtp_tls if you want to send via tls/ssl and are using ruby < 1.8.7
168
-
169
- == Meta
170
-
171
- Maintained by Ben Prew
172
-
173
- Written by Adam Wiggins
174
-
175
- Patches contributed by:
176
- * Adam Wiggins
177
- * Ben Prew
178
- * Cameron Matheson
179
- * Carl Hörberg
180
- * Daniel Lopes
181
- * Hiroshi Saito
182
- * Kalin Harvey
183
- * MIKAMI Yoshiyuki
184
- * Mathieu Martin
185
- * Michael Durrant
186
- * Neil Middleton
187
- * Neil Mock
188
- * Nickolas Means
189
- * Othmane Benkirane
190
- * Rich Meyers
191
- * Roman Franko
192
- * Ryan Malecky
193
- * Seamus Abshere
194
- * Stephen Celis
195
- * arunthampi
196
- * rick
197
- * rohit
198
-
199
- Released under the MIT License: http://www.opensource.org/licenses/mit-license.php
200
-
201
- homepage: http://github.com/benprew/pony
202
- mailing list: ponyrb@googlegroups.com
203
-
204
-
205
- == Releases
206
- 1.10
207
- * Add subject_prefix, append_options and override_options
208
-
209
- 1.9
210
- * Allow options to be queried from the gem
211
-
212
- 1.8
213
- * Add additional options for headers in each part of letter
214
-
215
- 1.7
216
- * Better default content_type with attachments
217
-
218
- 1.6
219
- * Unknown options are passed directly to mail to handle. Remove deprecated syntax
220
-
221
- 1.5.1
222
- * Loosen mail dependency to >= 2.0 instead of > 2.0
223
-
224
- 1.5
225
- * Specify content-id of attachments as filename@hostname
226
-
227
- 1.4.1
228
- * Update gemfile
229
-
230
- 1.4
231
- * Updated docs
232
-
233
- 1.3
234
- * Add new option :text_part_charset, which allows you to specify the charset for the text portion
235
-
236
- 1.2
237
- * Remove limitations on :via, and let mail handle it (this means you can say things like :via => test)
238
- * Add reply-to option and a bundler file
239
-
240
- 1.1
241
- * Add default options
242
-
243
- 1.0
244
- * Convert to using Mail as the mail-generation backend, instead of TMail
245
-
246
- 0.9.1
247
- * provide the ability to set custom mail headers with something like:
248
- Pony.mail(:headers => {"List-ID" => "..."})
249
- * provide the ability to set the Message-Id from Pony.mail
250
-
251
- 0.9
252
- * merge in kalin's fixes to use tmail.destinations instead of trying to parse tmail.to, tmail.cc and tmail.bcc. New specs to test functionality
253
-
254
- 0.8
255
- * Fix bug that was allowing nil :bcc and :cc options to be passed to smtp
256
-
257
- 0.7
258
- * Pass :cc and :bcc options to sendmail appropriately
259
-
260
- 0.6
261
- * Add :bcc capability
262
- * Add :charset capability
263
- * Add complete list of options to readme
264
- * fix bug: readme examples
265
-
266
- 0.5
267
- * default location of sendmail to /usr/sbin/sendmail if sendmail not in path
268
- * fix bug: README not showing password option (listed as pass)
269
-
270
- 0.4.1
271
- * Add :cc capability
272
- * fix bug: resolve body not displaying when attachments sent
273
-
274
- 0.4
275
- * Implemented file attachments option
276
- * use TLS if :tls => true