mail 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of mail might be problematic. Click here for more details.

@@ -1,3 +1,9 @@
1
+ == Thu Jan 28 00:25:02 UTC 2010 Mikel Lindsaar <raasdnil@gmail.com>
2
+
3
+ * Added TMM1's patch to not raise errors if a email is not multipart/report
4
+ * Added html_part and text_part now return the first text/html or text/plain part they find. Order is from top to bottom of the email, all parts, flattened.
5
+ * Version bump to 2.1.2
6
+
1
7
  == Mon Jan 25 11:36:13 UTC 2010 Mikel Lindsaar <raasdnil@gmail.com>
2
8
 
3
9
  * Added ability for address fields to init on an array instead of just a string.
@@ -219,11 +219,9 @@ what you are doing.
219
219
 
220
220
  === Sending an email:
221
221
 
222
- require 'mail'
223
-
224
- Mail.defaults do
225
- smtp '127.0.0.1', 25
226
- end
222
+ Mail defaults to sending via SMTP to local host port 25. If you have a
223
+ sendmail or postfix daemon running on on this port, sending email is as
224
+ easy as:
227
225
 
228
226
  Mail.deliver do
229
227
  from 'me@test.lindsaar.net'
@@ -235,10 +233,6 @@ what you are doing.
235
233
 
236
234
  or
237
235
 
238
- Mail.defaults do
239
- smtp '127.0.0.1' # Port 25 defult
240
- end
241
-
242
236
  mail = Mail.new do
243
237
  from 'me@test.lindsaar.net'
244
238
  to 'you@test.lindsaar.net'
@@ -249,6 +243,22 @@ or
249
243
 
250
244
  mail.deliver!
251
245
 
246
+ Sending via sendmail can be done like so:
247
+
248
+ mail = Mail.new do
249
+ from 'me@test.lindsaar.net'
250
+ to 'you@test.lindsaar.net'
251
+ subject 'Here is the image you wanted'
252
+ body File.read('body.txt')
253
+ add_file {:filename => 'somefile.png', :content => File.read('/somefile.png')}
254
+ end
255
+
256
+ mail.delivery_method :sendmail
257
+
258
+ mail.deliver
259
+
260
+ mail.deliver!
261
+
252
262
 
253
263
  === Getting emails from a pop server:
254
264
 
@@ -344,10 +354,6 @@ simple as possible.... (asking a lot from a mail library)
344
354
 
345
355
  require 'mail'
346
356
 
347
- Mail.defaults do
348
- smtp '127.0.0.1' # Port 25 defult
349
- end
350
-
351
357
  mail = Mail.deliver do
352
358
  to 'nicolas@test.lindsaar.net.au'
353
359
  from 'Mikel Lindsaar <mikel@test.lindsaar.net.au>'
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ require 'bundler'
12
12
 
13
13
  spec = Gem::Specification.new do |s|
14
14
  s.name = "mail"
15
- s.version = "2.1.1"
15
+ s.version = "2.1.2"
16
16
  s.author = "Mike Lindsaar"
17
17
  s.email = "raasdnil@gmail.com"
18
18
  s.homepage = "http://github.com/mikel/mail"
@@ -1379,31 +1379,31 @@ module Mail
1379
1379
  end
1380
1380
 
1381
1381
  def bounced?
1382
- delivery_status_part.bounced?
1382
+ delivery_status_part and delivery_status_part.bounced?
1383
1383
  end
1384
1384
 
1385
1385
  def action
1386
- delivery_status_part.action
1386
+ delivery_status_part and delivery_status_part.action
1387
1387
  end
1388
1388
 
1389
1389
  def final_recipient
1390
- delivery_status_part.final_recipient
1390
+ delivery_status_part and delivery_status_part.final_recipient
1391
1391
  end
1392
1392
 
1393
1393
  def error_status
1394
- delivery_status_part.error_status
1394
+ delivery_status_part and delivery_status_part.error_status
1395
1395
  end
1396
1396
 
1397
1397
  def diagnostic_code
1398
- delivery_status_part.diagnostic_code
1398
+ delivery_status_part and delivery_status_part.diagnostic_code
1399
1399
  end
1400
1400
 
1401
1401
  def remote_mta
1402
- delivery_status_part.remote_mta
1402
+ delivery_status_part and delivery_status_part.remote_mta
1403
1403
  end
1404
1404
 
1405
1405
  def retryable?
1406
- delivery_status_part.retryable?
1406
+ delivery_status_part and delivery_status_part.retryable?
1407
1407
  end
1408
1408
 
1409
1409
  # Returns the current boundary for this message part
@@ -1465,7 +1465,7 @@ module Mail
1465
1465
  add_multipart_alternate_header unless html_part.blank?
1466
1466
  add_part(@html_part)
1467
1467
  else
1468
- @html_part
1468
+ @html_part || find_first_mime_type('text/html')
1469
1469
  end
1470
1470
  end
1471
1471
 
@@ -1476,7 +1476,7 @@ module Mail
1476
1476
  add_multipart_alternate_header unless html_part.blank?
1477
1477
  add_part(@text_part)
1478
1478
  else
1479
- @text_part
1479
+ @text_part || find_first_mime_type('text/plain')
1480
1480
  end
1481
1481
  end
1482
1482
 
@@ -1649,6 +1649,14 @@ module Mail
1649
1649
  def filename
1650
1650
  find_attachment
1651
1651
  end
1652
+
1653
+ def all_parts
1654
+ parts.map { |p| [p, p.all_parts] }.flatten
1655
+ end
1656
+
1657
+ def find_first_mime_type(mt)
1658
+ all_parts.detect { |p| p.mime_type == mt }
1659
+ end
1652
1660
 
1653
1661
  private
1654
1662
 
@@ -28,8 +28,8 @@ module Mail
28
28
  # delivery_method :smtp, { :address => "smtp.gmail.com",
29
29
  # :port => 587,
30
30
  # :domain => 'baci.lindsaar.net',
31
- # :user_name => 'raasdnil',
32
- # :password => 'g333ma11',
31
+ # :user_name => '<username>',
32
+ # :password => '<password>',
33
33
  # :authentication => 'plain',
34
34
  # :enable_starttls_auto => true }
35
35
  # end
@@ -32,7 +32,7 @@ module Mail
32
32
  end
33
33
 
34
34
  def bounced?
35
- (action =~ /failed/i)
35
+ !!(action =~ /failed/i)
36
36
  end
37
37
 
38
38
  def action
@@ -3,7 +3,7 @@ module Mail
3
3
  module VERSION
4
4
  MAJOR = 2
5
5
  MINOR = 1
6
- TINY = 1
6
+ TINY = 2
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY].join('.')
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Lindsaar
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-25 00:00:00 +11:00
12
+ date: 2010-01-28 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency