From maarten at solovirtuoso.com Fri Jan 4 09:14:29 2008
From: maarten at solovirtuoso.com (Maarten Oelering)
Date: Fri, 4 Jan 2008 15:14:29 +0100
Subject: [Tmail-talk] (no subject)
Message-ID:
Hello,
I am currently considering using TMail to process inbound emails.
However I'm missing two features:
One is to retrieve the envelope sender which is often prepended to
the email using a From header without a colon. RubyMail supports this
with the mbox_from.
The other is to retrieve the IP address of the sender from the
Received: header. When I have for example:
Received: from mail.example.com (mail.example.com [1.2.3.4])
by ...
for ...
then neither TMail::ReceivedHeader#from nor
TMail::ReceivedHeader#body returns the part between brackets.
Is it thinkable that these features will be supported in the future?
Maybe anyone knows a workaround to get the raw body of a header field?
Regards,
Maarten
From u.alberton at gmail.com Fri Jan 4 15:25:25 2008
From: u.alberton at gmail.com (Bira)
Date: Fri, 4 Jan 2008 18:25:25 -0200
Subject: [Tmail-talk] Reading Forwarded Messages
Message-ID:
Hello,
First, I would like to apologize for asking a question which may be
obvious to the people here. I tried searching the documentation at
tmail.rubyforge.org, but I couldn't find any answers.
How does TMail handle forwarded messages? I've seen something in the
documentation about creating forwards, but I want to do the opposite -
given an e-mail message which contains one or more forwarded messages,
how do I acess them?
If the answer is indeed in the documentation, where could I find it? :)
--
Bira
http://compexplicita.blogspot.com
http://sinfoniaferida.blogspot.com
From u.alberton at gmail.com Fri Jan 4 16:08:00 2008
From: u.alberton at gmail.com (Bira)
Date: Fri, 4 Jan 2008 19:08:00 -0200
Subject: [Tmail-talk] Reading Forwarded Messages
In-Reply-To:
References:
Message-ID:
On Jan 4, 2008 6:25 PM, Bira wrote:
> Hello,
>
> First, I would like to apologize for asking a question which may be
> obvious to the people here. I tried searching the documentation at
> tmail.rubyforge.org, but I couldn't find any answers.
>
> How does TMail handle forwarded messages? I've seen something in the
> documentation about creating forwards, but I want to do the opposite -
> given an e-mail message which contains one or more forwarded messages,
> how do I acess them?
>
> If the answer is indeed in the documentation, where could I find it? :)
To prove I'm not a help vampire, here is what I managed to find out
since sending out the first message:
This is an example from the RDoc for TMail::Mail.create_forward:
mail = TMail::Mail.load("my_email")
forward_email = mail.create_forward
forward_email.class #=> TMail::Mail
forward_email.content_type #=> "multipart/mixed"
forward_email.body #=> "Attachment: (unnamed)"
forward_email.encoded #=> Returns the original email as a MIME attachment
Trying it out in IRB, I see that forward_mail.encoded returns a
string. Is there a similar method that returns a TMail::Mail object?
Again in IRB, I tried "re-parsing" this string using
TMail::Mail.parse, but I feel it didn't come out quite as it should.
If there isn't an already-made method for this, could someone give a
few starting tips on how to implement one myself, or point to some
documentation that does?
--
Bira
http://compexplicita.blogspot.com
http://sinfoniaferida.blogspot.com
--
Bira
http://compexplicita.blogspot.com
http://sinfoniaferida.blogspot.com
From riddochc at gmail.com Sat Jan 12 02:04:24 2008
From: riddochc at gmail.com (Chris Riddoch)
Date: Sat, 12 Jan 2008 00:04:24 -0700
Subject: [Tmail-talk] Message threading with jwz's algorithm
Message-ID: <6efbd9b70801112304l49abb840x260f669b1d4ed0f3@mail.gmail.com>
Hi,
Partly inspired (and reminded) by a certain blog post I stumbled
across on lindsaar.net about being a real programmer (*cough*), I feel
I should make a long overdue contribution to Tmail.
Several years ago, I wrote some code to take Tmail message objects and
build threads out of them, based on Jamie Zawinski's message
threading[1] algorithm. I modified it substantially, based on the
fact that jwz's doing a lot of pointer-silliness in C to do things
that are simpler done differently when you have Arrays as part of your
language. Yay, Ruby.
This has languished on my hard drive for nearly three years now. To
be honest, I'm a little ashamed to admit I'd never bothered to try to
submit this code for inclusion into TMail. It's not shining code -
badly commented, and written shortly after I started learning Ruby, so
it's kinda Perlish. But it worked, once upon a time, and with a
little love, could be useful to others.
Okay, enough with the caveats. How'd you like me to send it to you?
[1] http://www.jwz.org/doc/threading.html
--
epistemological humility
Chris Riddoch
From riddochc at gmail.com Tue Jan 15 15:48:56 2008
From: riddochc at gmail.com (Chris Riddoch)
Date: Tue, 15 Jan 2008 13:48:56 -0700
Subject: [Tmail-talk] Message threading code
Message-ID: <6efbd9b70801151248j312fdc2agab33dc669f1abab1@mail.gmail.com>
Hi,
This is the code I wrote for doing message threading. I don't see any
particular guidelines for contributing to tmail, I'm not even sure if
this is the right place to be sending this. I'm willing to help fix
it up for inclusion... and I could use another pair of eyeballs to
point out what I should do with it.
--
epistemological humility
Chris Riddoch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: readmail2.rb
Type: application/x-ruby
Size: 9376 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/tmail-talk/attachments/20080115/bfb4d6db/attachment.bin
From PBailey at bna.com Wed Jan 16 15:07:56 2008
From: PBailey at bna.com (Peter Bailey)
Date: Wed, 16 Jan 2008 15:07:56 -0500
Subject: [Tmail-talk] simple question, I think
Message-ID:
Hello,
I'm very green with regard to any Ruby mail stuff. I posted
a request on the Ruby forum to get some information on doing
a simple e-mail with an attachment. A nice guy responded
with a huge class that he'd made, just for mailing, using
net/smtp. But, I can't figure it out. So, I'd like to try
tmail.
Nowhere in the doc do I see anything about sending an
attachment. Can someone please help me to create a mailing
template for the following?
from: someguy at bna.com
to: pbailey at bna.com (that's me)
subject: "This is a test."
message: "blah, blah, blah"
attachment: c:\stufftext.pdf
smtp server: mail.bna.com (xx.xx.xx.xx)
Thanks a lot,
Peter
From raasdnil at gmail.com Thu Jan 17 00:00:57 2008
From: raasdnil at gmail.com (Mikel Lindsaar)
Date: Thu, 17 Jan 2008 16:00:57 +1100
Subject: [Tmail-talk] line wrapping
Message-ID: <57a815bf0801162100l2974ec83hef0a7a750839e996@mail.gmail.com>
| I'm trying to figure out if TMail automatically wraps lines (in the
| header) under any circumstances, and if so, under what circumstances.
| Any input would be much appreciated.
Heya Matt,
Sorry for the delay, I had some problems with the mailing list.
Yes, TMail does wrap headers, though previous versions didn't work so well.
Right now (as of version 1.2) it will wrap headers per RFC 2022, which
is basically like this:
Fold at less than 78 characters if there is an easy white space to wrap in
Otherwise fold at the first white space larger than 78.
If there is no white space, don't wrap unless it gets to 998
characters at which case it hard folds the line.
Regards
Mikel Lindsaar
From raasdnil at gmail.com Thu Jan 17 00:10:48 2008
From: raasdnil at gmail.com (Mikel Lindsaar)
Date: Thu, 17 Jan 2008 16:10:48 +1100
Subject: [Tmail-talk] simple question, I think
Message-ID: <57a815bf0801162110j19cac207h108dcf9ba1663b61@mail.gmail.com>
> I'm very green with regard to any Ruby mail stuff. I posted
> a request on the Ruby forum to get some information on doing
> a simple e-mail with an attachment. A nice guy responded
> with a huge class that he'd made, just for mailing, using
> net/smtp. But, I can't figure it out. So, I'd like to try
> tmail.
Good idea :)
> Nowhere in the doc do I see anything about sending an
> attachment. Can someone please help me to create a mailing
> template for the following?
What are you using TMail inside of? I have never really needed to
generate attachments in my applications.
TMail only handles the headers, not the body. So, there is no direct
way to attach an attachment to TMail. You have to go through it step
by step.
But maybe we could add something like
TMail::Mail#add_attachment(file_object). That might be cool.
Anyone want to help give that a shot?
Mikel
From raasdnil at gmail.com Thu Jan 17 00:16:41 2008
From: raasdnil at gmail.com (Mikel Lindsaar)
Date: Thu, 17 Jan 2008 16:16:41 +1100
Subject: [Tmail-talk] Message threading with jwz's algorithm
Message-ID: <57a815bf0801162116q724e534fj339a3640e539c112@mail.gmail.com>
> Partly inspired (and reminded) by a certain blog post I stumbled
> across on lindsaar.net about being a real programmer (*cough*), I feel
> I should make a long overdue contribution to Tmail.
You mean someone read my blog?!?!?! What the hell is going on around here??? :D
> Several years ago, I wrote some code to take Tmail message objects and
> build threads out of them, based on Jamie Zawinski's message
> threading[1] algorithm. I modified it substantially, based on the
> fact that jwz's doing a lot of pointer-silliness in C to do things
> that are simpler done differently when you have Arrays as part of your
> language. Yay, Ruby.
Now, that sounds cool.
> This has languished on my hard drive for nearly three years now. To
> be honest, I'm a little ashamed to admit I'd never bothered to try to
> submit this code for inclusion into TMail. It's not shining code -
> badly commented, and written shortly after I started learning Ruby, so
> it's kinda Perlish. But it worked, once upon a time, and with a
> little love, could be useful to others.
No problem!
> Okay, enough with the caveats. How'd you like me to send it to you
Well, you bring up a good point on how to contribute to TMail.
The simple thing is svn down the latest trunk:
svn checkout http://tmail.rubyforge.org/svn/ tmail-trunk
Then get in there and hack!
Patches and feature requests should be submitted via RubyForge's tracker.
Though, tell me more about this :) Where would you see it going in
and what sort of interface are we after?
Obviously it would have to hang off the TMail module directly as it
would reference multiple TMail objects, but what are your thoughts on
this?
Love to get your help! The more the merrier!
Mikel
From raasdnil at gmail.com Thu Jan 17 00:26:45 2008
From: raasdnil at gmail.com (Mikel Lindsaar)
Date: Thu, 17 Jan 2008 16:26:45 +1100
Subject: [Tmail-talk] Reading Forwarded Messages
Message-ID: <57a815bf0801162126t6de8e36bxeb573792a0c4a3a9@mail.gmail.com>
> On Jan 4, 2008 6:25 PM, Bira wrote:
> > First, I would like to apologize for asking a question which may be
> > obvious to the people here. I tried searching the documentation at
> > tmail.rubyforge.org, but I couldn't find any answers.
Hey, no problem, that is what this list is for, though I am sorry it
took me so darn long to answer you! :)
> > How does TMail handle forwarded messages? I've seen something in the
> > documentation about creating forwards, but I want to do the opposite -
> > given an e-mail message which contains one or more forwarded messages,
> > how do I acess them?
Ok, you have a file that has an image in it... you can do something like this:
irb> require 'rubygems'
irb> require 'tmail'
irb> m = TMail::Mail.load('email_with_attachment.txt')
irb> m.has_attachments?
=> true
irb> m.attachments
=> [#, #]
irb> m.attachments[0].read
<>
Basically, an attachment inherits from the StringIO class, and
StringIO class in TMail has the ability to read and write.
So you can just read in the file, then write it out to disk and you
should be good.
Hope that helps.
This is definately somewhere where a bit more documentation would be
useful. Wanna help out?
Mikel
From raasdnil at gmail.com Thu Jan 17 00:35:08 2008
From: raasdnil at gmail.com (Mikel Lindsaar)
Date: Thu, 17 Jan 2008 16:35:08 +1100
Subject: [Tmail-talk] (no subject)
Message-ID: <57a815bf0801162135x39c71b34kd9a09bf82bc041fc@mail.gmail.com>
> I am currently considering using TMail to process inbound emails.
> However I'm missing two features:
good to hear!
> One is to retrieve the envelope sender which is often prepended to
> the email using a From header without a colon. RubyMail supports this
> with the mbox_from.
I saw your RubyForge bug on this, and I think I fixed it in the latest
trunk. From the documentation in the trunk for this, you can now do
this:
=================
Returns a HeaderField object matching the header you specify in the
"name" param.
Requires an initialized TMail::Port to be passed in.
The method searches the header of the Port you pass into it to find a match on
the header line you pass. Once a match is found, it will unwrap the
matching line
as needed to return an initialized HeaderField object.
If you want to get the Envelope sender of the email object, pass in
"EnvelopeSender",
if you want the From address of the email itself, pass in 'From'.
This is because a mailbox doesn't have the : after the From that designates the
beginning of the envelope sender (which can be different to the from address of
the emial)
Other fields can be passed as normal, "Reply-To", "Received" etc.
Note: Change of behaviour in 1.2.1 => returns nil if it does not find
the specified
header field, otherwise returns an instantiated object of the correct
header class
For example:
port = TMail::FilePort.new("/test/fixtures/raw_email_simple")
h = TMail::HeaderField.new_from_port(port, "From")
h.addrs.to_s #=> "Mikel Lindsaar "
h = TMail::HeaderField.new_from_port(port, "EvelopeSender")
h.addrs.to_s #=> "mike at anotherplace.com.au"
h = TMail::HeaderField.new_from_port(port, "SomeWeirdHeaderField")
h #=> nil
=================
Does that do what you were after?
> The other is to retrieve the IP address of the sender from the
> Received: header. When I have for example:
> Received: from mail.example.com (mail.example.com [1.2.3.4])
> by ...
> for ...
> then neither TMail::ReceivedHeader#from nor
> TMail::ReceivedHeader#body returns the part between brackets.
> Is it thinkable that these features will be supported in the future?
Yeah! That's a good idea, we could have
TMail::ReceivedHeader#source_address or something.... hmm...
Sure, come on board and help out. You could grab the source and help
whack it in, I don't think that one would be too hard actually.
> Maybe anyone knows a workaround to get the raw body of a header field?
In the mean time, you could
From raasdnil at gmail.com Thu Jan 17 00:41:47 2008
From: raasdnil at gmail.com (Mikel Lindsaar)
Date: Thu, 17 Jan 2008 16:41:47 +1100
Subject: [Tmail-talk] (no subject)
In-Reply-To: <57a815bf0801162135x39c71b34kd9a09bf82bc041fc@mail.gmail.com>
References: <57a815bf0801162135x39c71b34kd9a09bf82bc041fc@mail.gmail.com>
Message-ID: <57a815bf0801162141m76c405a2ibd15e9410a866539@mail.gmail.com>
Oopss.. sent without completing the thought...
You can get to the raw body like this:
irb(main):055:0> m['received']
=> [#; Tue, 10 May 2005
15:27:05 -0500\n">, #; Tue, 10
May 2005 15:27:04 -0500\n">, #; Tue, 10 May 2005 15:27:03 -0500\n">]
irb(main):056:0> m['received'].length
=> 3
irb(main):057:0> m['received'][0].to_s
=> "from xxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id C1B953B4CB6 for
; Wed, 11 May 2005 06:27:05 +1000"
Hope that helps
Mikel
From maarten at solovirtuoso.com Thu Jan 17 03:37:20 2008
From: maarten at solovirtuoso.com (Maarten Oelering)
Date: Thu, 17 Jan 2008 09:37:20 +0100
Subject: [Tmail-talk] ReceivedHeader
In-Reply-To: <57a815bf0801162135x39c71b34kd9a09bf82bc041fc@mail.gmail.com>
References: <57a815bf0801162135x39c71b34kd9a09bf82bc041fc@mail.gmail.com>
Message-ID:
The suggested workaround, using mail['received'][0].to_s to get the
complete header line doesn't work. The to_s recreates the header line
from it's components. However the parser discards the part between
brackets so it is also not returned by to_s.
If the need arises I will think about a solution. However, the Racc
based parser doesn't look like it's easy to understand.
One general remark. I think TMail is an important component used by
many others, so I don't think anyone should "hack" or "whack"
something in. Maybe that was just a matter of speaking, but when "not
shining, badly commented, written shortly after starting to learn
Ruby, and kinda Perlish" code will be added, I would rather have a
well-written TMail without message threading.
Cheers,
Maarten O.
On 17-jan-2008, at 6:35, Mikel Lindsaar wrote:
>
>> The other is to retrieve the IP address of the sender from the
>> Received: header. When I have for example:
>> Received: from mail.example.com (mail.example.com [1.2.3.4])
>> by ...
>> for ...
>> then neither TMail::ReceivedHeader#from nor
>> TMail::ReceivedHeader#body returns the part between brackets.
>> Is it thinkable that these features will be supported in the future?
>
> Yeah! That's a good idea, we could have
> TMail::ReceivedHeader#source_address or something.... hmm...
>
> Sure, come on board and help out. You could grab the source and help
> whack it in, I don't think that one would be too hard actually.
>
>> Maybe anyone knows a workaround to get the raw body of a header
>> field?
>
> In the mean time, you could
On 17-jan-2008, at 6:41, Mikel Lindsaar wrote:
> Oopss.. sent without completing the thought...
>
> You can get to the raw body like this:
>
> irb(main):055:0> m['received']
> => [# ESMTP id C1B953B4CB6 for ; Tue, 10 May 2005
> 15:27:05 -0500\n">, # by xxx.xxxx.xxx with ESMTP id ca for ; Tue, 10
> May 2005 15:27:04 -0500\n">, # xxx.xxxx.xxx by SMS-GTYxxx.xxxx.xxx with ESMTP id j4AKR3r23323 for
> ; Tue, 10 May 2005 15:27:03 -0500\n">]
>
> irb(main):056:0> m['received'].length
> => 3
>
> irb(main):057:0> m['received'][0].to_s
> => "from xxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id C1B953B4CB6 for
> ; Wed, 11 May 2005 06:27:05 +1000"
>
>
> Hope that helps
>
>
> Mikel
> _______________________________________________
> Tmail-talk mailing list
> Tmail-talk at rubyforge.org
> http://rubyforge.org/mailman/listinfo/tmail-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/tmail-talk/attachments/20080117/b15450cb/attachment.html
From maarten at solovirtuoso.com Thu Jan 17 04:06:46 2008
From: maarten at solovirtuoso.com (Maarten Oelering)
Date: Thu, 17 Jan 2008 10:06:46 +0100
Subject: [Tmail-talk] ReceivedHeader
In-Reply-To: <57a815bf0801170053n687edb5bga7e898feec461255@mail.gmail.com>
References: <57a815bf0801162135x39c71b34kd9a09bf82bc041fc@mail.gmail.com>
<57a815bf0801170053n687edb5bga7e898feec461255@mail.gmail.com>
Message-ID: <6FBBEBF6-4143-4F17-BBA6-5BDFF0DE0A30@solovirtuoso.com>
On 17-jan-2008, at 9:53, Mikel Lindsaar wrote:
> In any case, my actions speak louder than perhaps my poor choice of
> words, since I have taken over the library (in November) every release
> has gotten more and more of the existing tests passing, when I took
> over the library, there were about 30 tests failing, there are now
> zero failing, plus about 200 more tests, plus compatibility with Ruby
> 1.9
Thanks for you reply. You cleared up my concerns. I'm impressed by,
and grateful for your work in TMail. I was just afraid that others
might have a "license to hack" into TMail, which is appearantly not
the case.
Maarten O.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/tmail-talk/attachments/20080117/c0f74fd9/attachment-0001.html
From raasdnil at gmail.com Thu Jan 17 09:49:24 2008
From: raasdnil at gmail.com (Mikel Lindsaar)
Date: Fri, 18 Jan 2008 01:49:24 +1100
Subject: [Tmail-talk] How to contribute to TMail
Message-ID: <57a815bf0801170649hb76ef72r5e0496c24ec289d3@mail.gmail.com>
Hello all,
I have had a few requests to help out contributing to TMail, I thought
I would let the list know how to do it.
I have written a short write up on the TMail website,
http://tmail.rubyforge.org/contributing/index.html which walks you
though the process.
It should answer any questions you have, if not, please let me know!
Regards
Mikel
From maarten at solovirtuoso.com Wed Jan 23 09:43:29 2008
From: maarten at solovirtuoso.com (Maarten Oelering)
Date: Wed, 23 Jan 2008 15:43:29 +0100
Subject: [Tmail-talk] ReceivedHeader
In-Reply-To: <57a815bf0801170458h6cc5dc44g629e08e789d0c1f0@mail.gmail.com>
References: <57a815bf0801162135x39c71b34kd9a09bf82bc041fc@mail.gmail.com>
<57a815bf0801170053n687edb5bga7e898feec461255@mail.gmail.com>
<6FBBEBF6-4143-4F17-BBA6-5BDFF0DE0A30@solovirtuoso.com>
<57a815bf0801170239q2a753c1dkf34ba3cd57f71466@mail.gmail.com>
<6C57E4FE-B3ED-48DC-B620-FFF12A2C85C6@solovirtuoso.com>
<57a815bf0801170419x327a9191n35baec3afb85bffe@mail.gmail.com>
<9E8538BA-07A4-4867-A22A-8C89A28CE434@solovirtuoso.com>
<57a815bf0801170458h6cc5dc44g629e08e789d0c1f0@mail.gmail.com>
Message-ID:
Hi Mikel,
I studied the TMail parser for extending the ReceivedHeader with
trace information. The current Yacc rules do not support the
"extended-domain" syntax which may include a "tcp-info" block after
the from-domain and by-domain. See also RFC 2821 section 4.4.
The Racc parser is a bit too complex for me to fully understand yet
so I don't feel comfortable to make changes the parser. However I
noticed that ReceivedHeader#comments does return the "tcp-info" block
since it is enclosed in brackets.
This provides me with an acceptable workaround. As soon as I have
learned more about the parser I might give it another try.
Cheers,
Maarten O.
On 17-jan-2008, at 13:58, Mikel Lindsaar wrote:
> On Jan 17, 2008 11:53 PM, Maarten Oelering
> wrote:
>> I checked out the code and was able to run the tests. So I should be
>> set for now.
>> svn checkout http://tmail.rubyforge.org/svn/trunk
>> cd trunk
>> rake test
>> 204 tests, 4014 assertions, 0 failures, 0 errors
>
> Great!
>
>> I have ruby 1.8.5 on my local (OS-X) system. Let me know if Tmail
>> development requires me to upgrade.
>
> Not at all. The stable datum is the tests - in fact, it shows that we
> are good with 1.8.5 as well :) If they pass we are cool. When you
> make a patch, I will test it against ruby 1.8.6 and 1.9 and help patch
> anything.
>
> Regards
>
> Mikel
From raasdnil at gmail.com Wed Jan 23 19:47:57 2008
From: raasdnil at gmail.com (Mikel Lindsaar)
Date: Thu, 24 Jan 2008 11:47:57 +1100
Subject: [Tmail-talk] ReceivedHeader
In-Reply-To:
References: <57a815bf0801162135x39c71b34kd9a09bf82bc041fc@mail.gmail.com>
<57a815bf0801170053n687edb5bga7e898feec461255@mail.gmail.com>
<6FBBEBF6-4143-4F17-BBA6-5BDFF0DE0A30@solovirtuoso.com>
<57a815bf0801170239q2a753c1dkf34ba3cd57f71466@mail.gmail.com>
<6C57E4FE-B3ED-48DC-B620-FFF12A2C85C6@solovirtuoso.com>
<57a815bf0801170419x327a9191n35baec3afb85bffe@mail.gmail.com>
<9E8538BA-07A4-4867-A22A-8C89A28CE434@solovirtuoso.com>
<57a815bf0801170458h6cc5dc44g629e08e789d0c1f0@mail.gmail.com>
Message-ID: <57a815bf0801231647x543dd4baq40f3a5d9909a997f@mail.gmail.com>
On Jan 24, 2008 1:43 AM, Maarten Oelering wrote:
> This provides me with an acceptable workaround. As soon as I have
> learned more about the parser I might give it another try.
Sounds good!
Thanks for your work.
Would you be willing to make a documentation patch in the appropriate
spot on how to get this header information with an example of your
work around? That way we won't have to answer this question again.
Regards
Mikel