11件ヒット
[1-11件を表示]
(0.050秒)
別のキーワード
検索結果
先頭1件
-
net
/ smtp (38090.0) -
メールを送信するためのプロトコル SMTP (Simple Mail Transfer Protocol) を扱うライブラリです。
...す。
ブロックを使うと File.open と同じように終端処理を自動的にやってくれる
のでおすすめです。
require 'net/smtp'
Net::SMTP.start( 'smtp.example.com', 25 ) {|smtp|
# use smtp object only in this block
}
smtp-server.example.com は適切な SMTP サ......re 'net/smtp'
Net::SMTP.start('smtp.example.com', 25) {|smtp|
smtp.send_message(<<-EndOfMail, 'from@example.com', 'to@example.net')
From: Your Name <from@example.com>
To: Dest Address <to@example.net>
Subject: test mail
Date: Sat, 23 Jun 2001 16:26:43 +0900
Message-Id: <unique.mes......sage.id.string@yourhost.example.com>
This is a test mail.
EndOfMail
}
==== セッションを終了する
メールを送ったら Net::SMTP#finish を呼んで
セッションを終了しなければいけません。
File のように GC 時に勝手に close されることもあり...