From: Jeremy McAnally Date: 2008-11-18T01:20:16+09:00 Subject: Re: [solved, kinda] Re: Why does tmail stop my CGI script form working? 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. --Jeremy On Mon, Nov 17, 2008 at 3:49 AM, Chad Perrin wrote: > Unable to get tmail working properly on my shared hosting account, I > decided to take a whack at using the command line `mail` program instead > of tmail and net/smtp. I'd appreciate any commentary that might help me > fix this up, in case of bugs or security concerns. The end result looks > somewhat like this: > > #!/usr/bin/env ruby > require 'rubygems' > require 'cgi' > > cgi = CGI.new > print "Content-Type: text/html\n\n" > > args = cgi.params > > args.each_key do |k| > args[k] = args[k].to_s.gsub(/"/, "''") > end > > body_c = " > > name: #{args['realname']} > email: #{args['email']} > tel.: #{args['telephone']} > > #{args['comments']} > " > > > sub_c = "AL Contact Form: #{args['subject']}" > to_c = 'user@example.com' > > `echo "#{body_c}" | mail -s '#{sub_c}' #{to_c}` > > puts '' > > Obviously, "example.com" isn't the real domain name, and "user" isn't the > actual user name. > > I'm sure you'll notice the quote-replacement code. Nothing else comes to > mind that'd constitute a problematic character to send to the shell, but > if you know of any others I'd like to hear about it. I looked around for > a string sanitizer appropriate to my needs here, but didn't find anything > in the standard library or core language, and if I start adding gems I'm > going to end up with the same problem I had trying to get tmail and rmail > to work (yeah, I tried rmail too -- same problem). > > -- > Chad Perrin [ content licensed PDL: http://pdl.apotheon.org ] > Quoth Thomas McCauley: "The measure of a man's real character is what he > would do if he knew he would never be found out." > -- http://jeremymcanally.com/ http://entp.com/ http://omgbloglol.com My books: http://manning.com/mcanally/ http://humblelittlerubybook.com/ (FREE!)