Francis said:
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'] = '(e-mail address removed)'
msg.header['From'] = '(e-mail address removed)'
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/