Created
February 10, 2009 09:31
-
-
Save brendano/61320 to your computer and use it in GitHub Desktop.
mail cgi for curl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
puts "Content-Type: text/plain" | |
puts | |
subj = ENV['PATH_INFO'] || "" | |
subj.gsub!("'", '"') | |
msg = STDIN.read || "" | |
# system "env" | |
# puts subj | |
# puts | |
# puts msg | |
f = open("|mail -s '#{subj}' [email protected] 2>&1", 'r+') | |
f.write msg | |
f.write "\n\n" | |
f.write "Sender IP is #{ENV['REMOTE_ADDR']}\n" | |
# f.write ENV.to_hash.map{|k,v| "%-15s %s" % [k,v]}.join("\n") | |
# f.puts | |
# f.puts "." # wtf why does this stop an error | |
f.close_write | |
out = f.read | |
f.close | |
# puts "Seems to have sent." | |
puts out unless out.empty? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment