On Thu, 23 Sep 2004 05:09:02 +0900, Chris Morris wrote
> Anyone have a snippet or link to a snippet for setting up an email
> with HTML formatting? Does it have to be a multipart MIME yada yada
> with plain-text accompaniment, or can I skip that and just have html
> in it and keep it simple?

If you want it to be an HTML only email, it's trivial.

I tend to use the tmail library because it's simple and works for me.

To use it, do something similar to:


require 'tmail'

mail = TMail::Mail.new
mail.to = to_address
mail.from = from_address
mail.reply_to = reply_address
mail.subject = 'My Email'
mail.date = Time.now
mail.set_content_type = 'text','html'
mail.body = <<EMAIL
<head><title>My Mail</title></head>
<body><h1>Here is my HTML mail!</h1></body>
EMAIL

sm = IO.popen("/usr/sbin/sendmail -i -t","w+")
sm.print mail.encoded
sm.flush


Kirk Haines