According to the RubyMail NEWS file at https://github.com/matta/rubymail/blob/master/NEWS , this library is supposed to be usable with Ruby 1.9. However, when used with Ruby 1.9, it breaks one of my scripts that uses Net::SMTP to send a message created using RubyMail.
A modified snippet of the test script is as follows, where if you run it with Ruby 1.9, you will get a NoMethodError exception. [BEGIN] #! /usr/local/bin/ruby19 require 'rubygems' require 'rmail' require 'net/smtp' msg = RMail::Message.new msg.header["To"] = "b...@example.com" msg.header["Subject"] = "Test subject" msg.body = "This is just a test" begin Net::SMTP.start("smtp.example.com", 25, "example.net") do |smtp| smtp.send_message msg, "al...@example.net", [ "b...@example.com" ] end rescue Exception => e puts "#{e.class} #{e}" end [END] This is because smtp.send_message causes RubyMail's message.rb to call String.each, but the String class in Ruby 1.9 no longer has the each() method. The following diff patches the message.rb to fix this issue. The fix is backwards compatible with Ruby 1.8, since Ruby 1.8's String does have an each() method. I have also changed my email address in the port's Makefile. If this looks ok, could a developer please commit this? Thank you, Lawrence Index: Makefile =================================================================== RCS file: /cvs/ports/mail/ruby-rmail/Makefile,v retrieving revision 1.10 diff -u -p -r1.10 Makefile --- Makefile 16 Sep 2011 10:31:22 -0000 1.10 +++ Makefile 22 Jan 2012 03:19:24 -0000 @@ -3,12 +3,12 @@ COMMENT= Ruby library to create and parse MIME messages DISTNAME= rmail-1.0.0 -REVISION = 6 +REVISION = 7 CATEGORIES= mail HOMEPAGE= http://github.com/matta/rubymail -MAINTAINER= Lawrence Teo <lteo.openb...@calyptix.com> +MAINTAINER= Lawrence Teo <l...@lteo.net> # BSD PERMIT_PACKAGE_CDROM= Yes Index: patches/patch-lib_rmail_message_rb =================================================================== RCS file: patches/patch-lib_rmail_message_rb diff -N patches/patch-lib_rmail_message_rb --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-lib_rmail_message_rb 22 Jan 2012 03:19:24 -0000 @@ -0,0 +1,16 @@ +$OpenBSD$ + +This change is required in order for an RMail message to be sent with Net::SMTP +using Ruby 1.9 (since Ruby 1.9's String class does not have the each() method). + +--- lib/rmail/message.rb.orig Wed Dec 31 19:00:00 1969 ++++ lib/rmail/message.rb Sat Jan 21 21:22:20 2012 +@@ -161,7 +161,7 @@ module RMail + def each() + # FIXME: this is incredibly inefficient! The only users of this + # is RMail::Deliver -- get them to use a RMail::Serialize object. +- to_s.each("\n") { |line| ++ to_s.each_line("\n") { |line| + yield line + } + end