appears to change when are iterated through #119

novemberkilo opened this Issue Oct 14, 2010 · 2 comments


None yet
2 participants
require 'rubygems'
require 'mail'

mail = do
  to ''
  from ''
  subject 'Plain text email - constructed in Ruby'

text_part = do
   body 'This is plain text'

mail.text_part = text_part

puts "mail has #{mail.part.length.to_s} parts"
puts "---"

mail.part.each do |x|
  puts x.to_s
  puts "---"

puts "mail has #{mail.part.length.to_s} parts"

Here, even though we have a plain text email with one part, initially returns 2 and after iterating through the parts of mail, returns 4. The correct answer of course, is 1. When you play with this in irb and repeat the { |x| ... }

new parts appear (with headers only and no body).


jeremy commented Jan 26, 2013

When you call mail.part you're adding a new part each time. Use

@jeremy jeremy closed this Jan 26, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment