Forum: Ruby TMail question / ?error?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Bb118b6226ebc13ac995cb349c43d6c6?d=identicon&s=25 Rohit Mehta (Guest)
on 2006-05-31 17:34
(Received via mailing list)
Hi I am trying to write a Ruby program to test our antispam filter.  So
the first
part of my strategy is to take a bunch of spam and a bunch of notspam
which I've sorted into two mozilla-thunderbird mbox files and pump them
into the

However, I may be getting stuck with Ruby syntax.  The following code
works properly:

require 'tmail'
@loader ='spamfile')
@loader.each_port do |port|
 do something with the mail

However the following fails:

ro@atlas:/tmp$ irb
irb(main):001:0> require 'tmail'
=> true
irb(main):002:0> @loader ='spamfile')
=> #<TMail::UNIXMbox:0xb7aceb40 @readonly=false, @filename="spamfile",
@closed=false, @real=#<TMail::MhMailbox
irb(main):003:0> port = @loader.new_port
=> #<TMail::MhPort /tmp/ruby_tmail_8378_0.860064296748723/1>
irb(main):004:0> mail =
Errno::ENOENT: No such file or directory -
       from (irb):4

I noticed that when the @loader.each_port do loop starts it creates a
directory full of files
in /tmp, and each appears to be a file containing a single message from
my mbox file,
but @loader.new_port does not do this.  Is new_port not working
properly?  (I'm looking
at mailbox.rb, but I'm not sure that I understand what's going on)

The reason I want to do things this way is because I want to create
wrapper classes
SpamSource and NotSpamSource so I can send a controlled percentage of
spam to our gateway.
I'd like to be able to do:

if (a<spamPercentage)
message = mySpamSource.getMessage
message = myNotSpamSource.getMessage
dosomething with message

Am I doing something wrong?

956f185be9eac1760a2a54e287c4c844?d=identicon&s=25 ts (Guest)
on 2006-05-31 17:59
(Received via mailing list)
>>>>> "R" == Rohit Mehta <> writes:

R> but @loader.new_port does not do this.  Is new_port not working
R> properly?  (I'm looking

 Well #new_port returns a new TMail::Port, which must be used with
 or #aopen to create a new message, no ?

Guy Decoux
Bb118b6226ebc13ac995cb349c43d6c6?d=identicon&s=25 Rohit Mehta (Guest)
on 2006-05-31 18:34
(Received via mailing list)
Ahh, "new_port" does not do what I imagined it did.
I am really looking for a "next_port" method.  Perhaps the easiest
thing to do would be to use "each_port" to extract the MBox file into
a separate file and then work with the files.


This topic is locked and can not be replied to.