brendano (owner)

Revisions

gist: 61320 Download_button fork
public
Description:
mail cgi for curl
Public Clone URL: git://gist.github.com/61320.git
Embed All Files: show embed
CGI script that mails. easy to send mail via curl from a machine where "mail"/"mailx" doesnt work #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/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}' brenocon@gmail.com 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?