From: James Gray Date: 2008-11-18T05:05:32+09:00 Subject: Re: [solved, kinda] Re: Why does tmail stop my CGI script form working? On Nov 17, 2008, at 1:54 PM, Chad Perrin wrote: > On Tue, Nov 18, 2008 at 03:45:37AM +0900, James Gray wrote: >> On Nov 17, 2008, at 11:38 AM, Chad Perrin wrote: >> >>> On Tue, Nov 18, 2008 at 01:20:16AM +0900, Jeremy McAnally wrote: >>>> Why not try mailfactory if you're just sending e-mail? If it's >>>> just >>>> tmail screwing up. I thought perhaps you were parsing e-mail or >>>> something. >>> >>> The problem actually appears to be one of something on the server >>> being >>> misconfigured so that I cannot properly install and `require` gems. >>> >>> Also . . . as someone pointed out to me off-list, I forgot to >>> change a >>> set of single quotes in the `mail` command into double quotes. The >>> line >>> in question should actually read: >>> >>> `echo "#{body_c}" | mail -s "#{sub_c}" #{to_c}` >> >> I would prefer to just avoid passing the body through the shell: >> >> open(%Q{| mail -s "#{sub_c}" #{to_c}}, "w") { |mail| mail << >> body_c } > > That's an excellent point, and I wish I had thought of it. I took > your > advice. The relevant code now looks like this: > > sent = open( %Q{| mail -s "#{sub_c}" #{to_c} }, 'w' ) do |msg| > msg << body_c > end Is sent meant to contain the output? If so, we should probably change that code to: sent = open(%Q{| mail -s"#{sub_c}" #{to_c} }, "r+") do |mail| mail << body_c mail.close_write mail.read end >> You could use mail's escapes to avoid passing the subject as well. >> See the man page for details. > > I pored over the man page for a little while, and didn't catch on to > what > you meant by this. The closest I found to it was the reference to > the ~s > escape for the mail program, but I haven't figured out yet what you > meant > should be done with it if that's your point. I've never used that feature myself, but I suspect you would use it like this: mail << "~s #{sub_c}\n#{body_c}" I'm guessing though and could be wrong. Double check me there. James Edward Gray II