Getting the Message-Id for an outgoing email

Anybody know how I can get the Message-Id that’s assigned to an
outgoing message when I send by using the SMTP class? It looks like I
can set the Message-Id myself, so then I’ll have it, but that seems
like a lot of work. It’d be just easier to let sendmail set it and get
it back.

Francis

Francis Hwang wrote:

Anybody know how I can get the Message-Id that’s assigned to an
outgoing message when I send by using the SMTP class? It looks like I
can set the Message-Id myself, so then I’ll have it, but that seems
like a lot of work. It’d be just easier to let sendmail set it and get
it back.

Francis

This doesn’t solve the problem the way you’ve asked, but perhaps it’s
good enough. Have you scrutinized RubyMail? [1] It’s really good.
I’ve had to gus around with e-mail quite a bit lately and this package
has cut my work in half.

So, here’s the deal with it: it’s a library for parsing e-mail, but you
can also generate new messages with it. It has an add_message_id method
in the RMail::Header class that will generate new message IDs for you.

msg = RMail::Message.new
msg.header[‘To’] = ‘you@rubyadventureparadise.com’
msg.header[‘From’] = ‘me@rubyflavouredbrandsoda.com’
msg.body = ‘I like you sooo much. Come have soda!’
msg.header.add_message_id

msg_id = mail.header.message_id
Net::SMTP.start( ‘localhost’ ) do |smtp|
smtp.send_message( msg.to_s, msg.header[‘From’], msg.header[‘To’] )
end

Something like that. Haven’t tested that last part, but forage thru the
docs. [2] Start with ‘guide/Intro.txt’.

_why

[1] http://www.lickey.com/rubymail/
[2] http://www.lickey.com/rubymail/rubymail/doc/

That solution probably would’ve worked, except I’ve already got a
bunch of code that looks a lot like that anyway and switching would’ve
been a pain. I ended up just implementing it myself following Jamie
Zawinski’s recommendations at Recommendations for generating Message IDs .

Francis

why the lucky stiff ruby-talk@whytheluckystiff.net wrote in message news:40846067.9070209@whytheluckystiff.net

···

Francis Hwang wrote:

Anybody know how I can get the Message-Id that’s assigned to an
outgoing message when I send by using the SMTP class? It looks like I
can set the Message-Id myself, so then I’ll have it, but that seems
like a lot of work. It’d be just easier to let sendmail set it and get
it back.

Francis

This doesn’t solve the problem the way you’ve asked, but perhaps it’s
good enough. Have you scrutinized RubyMail? [1] It’s really good.
I’ve had to gus around with e-mail quite a bit lately and this package
has cut my work in half.

So, here’s the deal with it: it’s a library for parsing e-mail, but you
can also generate new messages with it. It has an add_message_id method
in the RMail::Header class that will generate new message IDs for you.

msg = RMail::Message.new
msg.header[‘To’] = ‘you@rubyadventureparadise.com’
msg.header[‘From’] = ‘me@rubyflavouredbrandsoda.com’
msg.body = ‘I like you sooo much. Come have soda!’
msg.header.add_message_id

msg_id = mail.header.message_id
Net::SMTP.start( ‘localhost’ ) do |smtp|
smtp.send_message( msg.to_s, msg.header[‘From’], msg.header[‘To’] )
end

Something like that. Haven’t tested that last part, but forage thru the
docs. [2] Start with ‘guide/Intro.txt’.

_why

[1] http://www.lickey.com/rubymail/
[2] http://www.lickey.com/rubymail/rubymail/doc/