Sha256: bf146c4db6adbc1c3b01c5bdc2db7fdcf3704c1c9354738dd0d996c4b0eec792

Contents?: true

Size: 697 Bytes

Versions: 3

Compression:

Stored size: 697 Bytes

Contents

# -*- coding: utf-8 -*-
require 'net/smtp'
require "nkf"

if __FILE__ ==$0
  $: << '../..'
  require 'keystone'
end

module Keystone
  module Mail
    class Send
      def self.sendmail(from, to, subject, body, host = "localhost", port = 25)
        body = <<EOT
From: #{from}
To: #{to.to_a.join(",\n ")}
Subject: #{NKF.nkf("-WMm0j", subject)}
Date: #{Time::now.strftime("%a, %d %b %Y %X %z")}
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-2022-JP
Content-Transfer-Encoding: 7bit

#{body}
EOT

        body = NKF.nkf("-Wj", body).force_encoding("ASCII-8BIT")

        Net::SMTP.start(host, port) do |smtp|
          smtp.send_mail body, from, to
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
keystone-0.0.32 lib/keystone/mail/send.rb
keystone-0.0.31 lib/keystone/mail/send.rb
keystone-0.0.30 lib/keystone/mail/send.rb