#======== コンストラクタ ========
#
#ホスト、ポート、あて先、差出人とか
#
#============================
def initialize( )
@host = "localhost"
@port = 25
@to = ""
@from = "webmaster@scoutroll.net"
end
#======== メールの送信メソッド ========
#
#メール送信
#
#=================================
def send_mail(subject, msg, send_to)
@to = send_to
#題名を jis & base64 エンコード
subject = " =?" + "iso-2022-jp" + "?B?" +
encode64(Kconv.tojis(subject)).chomp + "?="
#メール本文組み立て
mail_text = <<-EndOfMail
To: #{@to}
From: #{@from}
Subject: #{subject}
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-2022-jp"
Content-Transfer-Encoding: 7bit
EndOfMail
#本文を jis エンコード
mail_text = mail_text + Kconv.tojis(msg.to_s)
begin
#偽メアドのためにタイムアウトを設ける
timeout(20) do
Net::SMTP.start( @host, @port ) do |smtp|
smtp.send_mail( mail_text, @from, @to )
end
end
rescue
end
end
end
呼び出し元、インスタンス