̃Gg[͂ĂȃubN}[Nɒlj

Ruby :: イディオム / 手軽にメール送信する



mailstr = 'Subject: test mail
From: hoge@example.com
To: fuga@example.com
Date: Thu, 21 Sep 2099 11:03:15 +0900 (JST)
Mime-version: 1.0
 
あいうえお'
 
 
SENDMAIL = '/usr/sbin/sendmail'
addr = 'hoge@example.com'
to   = 'fuga@example.com'
 
IO.popen("#{SENDMAIL} -i -f#{addr} #{to}", 'w') do |fp|
	fp.puts mailstr
end



programming/ruby/idiom/send_mail.txt