# Recommended mailbox parsing library

**URL:** <https://www.ruby-forum.com/t/recommended-mailbox-parsing-library/81519>\
**Category:** Ruby\
**Created:** [January 9, 2007, 4:49pm UTC](https://www.ruby-forum.com/t/recommended-mailbox-parsing-library/81519 "2007-01-09T16:49:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [January 9, 2007, 4:49pm UTC](https://www.ruby-forum.com/t/recommended-mailbox-parsing-library/81519/1 "2007-01-09T16:49:04Z")

</div>

Are any of the ruby email parsing libraries currently maintained? I  
looked at rubymail and tmail, but neither seem to have been updated  
recently - is anyone currently using either of them (or some other  
ruby lib) to read and process a mailbox (in mbox format)?

martin

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [January 9, 2007, 4:56pm UTC](https://www.ruby-forum.com/t/recommended-mailbox-parsing-library/81519/2 "2007-01-09T16:56:05Z")

</div>

On Wed, 10 Jan 2007, Martin DeMello wrote:

> Are any of the ruby email parsing libraries currently maintained? I looked  
> at rubymail and tmail, but neither seem to have been updated recently - is  
> anyone currently using either of them (or some other ruby lib) to read and  
> process a mailbox (in mbox format)?

i use tmail extensively to manage data streams via remote and local  
mailboxes.  
i think it’s more the case that it’s ‘mature’ than the case that it’s  
not  
being maintained. the library is really quite complete to the extent  
that one  
sometimes has to rtfm for a while before being able to do a particular  
task -  
there’s just a lot there.

cheers.

-a

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [January 9, 2007, 5:24pm UTC](https://www.ruby-forum.com/t/recommended-mailbox-parsing-library/81519/3 "2007-01-09T17:24:08Z")

</div>

On 1/9/07, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> sometimes has to rtfm for a while before being able to do a particular task -  
> there’s just a lot there.

The following simple count-messages test returned the correct count,  
but replaced my mailbox with a zero-byte file - any idea what I’m  
doing wrong? This is with tmail 0.10.8

require ‘tmail’

i = 0

loader = TMail::UNIXMbox.new( ‘mailbox’ )  
loader.each\_port do |port|  
mail = TMail::Mail.new(port)  
i += 1  
puts i  
end

puts i

martin

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [January 9, 2007, 5:54pm UTC](https://www.ruby-forum.com/t/recommended-mailbox-parsing-library/81519/4 "2007-01-09T17:54:13Z")

</div>

On 1/9/07, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > loader = TMail::UNIXMbox.new( ‘mailbox’ )
> 
> at\_exit{ loader.close }
> 
> you may also check to see if ‘new’ takes a block - not sure if it does.  
> either way, the mbox can still be truncated if your process is 'kill -9’d.  
> for that reason i generally impliment a transaction on top of tmail’s.

Ah - thanks! I thought the each\_port block would close the file.

martin

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [January 9, 2007, 5:49pm UTC](https://www.ruby-forum.com/t/recommended-mailbox-parsing-library/81519/5 "2007-01-09T17:49:12Z")

</div>

On Wed, 10 Jan 2007, Martin DeMello wrote:

> The following simple count-messages test returned the correct count,  
> but replaced my mailbox with a zero-byte file - any idea what I’m  
> doing wrong? This is with tmail 0.10.8
> 
> require ‘tmail’
> 
> i = 0
> 
> loader = TMail::UNIXMbox.new( ‘mailbox’ )

at\_exit{ loader.close }

> loader.each\_port do |port|  
> mail = TMail::Mail.new(port)  
> i += 1  
> puts i  
> end
> 
> puts i

you may also check to see if ‘new’ takes a block - not sure if it does.  
either way, the mbox can still be truncated if your process is 'kill  
-9’d.  
for that reason i generally impliment a transaction on top of tmail’s.

regards.

-a
