diff options
author | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-07-11 21:35:32 +0000 |
---|---|---|
committer | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-07-11 21:35:32 +0000 |
commit | 6ad9e205044e75400c68331956927b5e091e7403 (patch) | |
tree | 9f4074d3ed3a5b8721066facbf24ac8355c12ca6 | |
parent | fa848fb6fdaab3e65b1aace32593424a9b07bff8 (diff) |
* doc/net/smtp.rd.ja: add note for RubyMail/TMail.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | doc/net/smtp.rd.ja | 205 |
1 files changed, 205 insertions, 0 deletions
diff --git a/doc/net/smtp.rd.ja b/doc/net/smtp.rd.ja new file mode 100644 index 0000000000..7a748947d7 --- /dev/null +++ b/doc/net/smtp.rd.ja @@ -0,0 +1,205 @@ +=begin + += net/smtp.rb + +== ���Υ饤�֥��ˤĤ��� + +�����������뤿��Υץ��ȥ��� SMTP (Simple Mail Transfer Protocol) +���饤�֥��Ǥ����إå��ʤɥ��Υǡ��������ȤϤǤ��ޤ��� +SMTP �μ����� RFC2821 �˴𤤤Ƥ��ޤ��� + + * RFC2821 ((<URL:http://www.ietf.org/rfc/rfc2821.txt>)) + +== �����Խ��ˤĤ��� + +���Υ饤�֥�꤬�Ǥ���Τ����������Ǥ������إå����Խ���ǽ�ʤɤ� +����ޤ����٤��Խ���ǽ��ɬ�פʤ顢TMail �� RubyMail �Τ褦�� +�饤�֥���ʻ�Ѥ��Ƥ���������������� RAA �������������ɤǤ��ޤ��� +�ޤ������ͥåȥ��ե����ޥåȤ������ʵ��ʽ�� RFC2822 �Ǥ��� + + * RAA ((<URL:http://www.ruby-lang.org/en/raa.html>)) + * RFC2822 ((<URL:http://www.ietf.org/rfc/rfc2822.txt>)) + +== ������ + +=== �Ȥˤ����������� + +SMTP ��Ȥäƥ�������ˤϤޤ� SMTP.start �ǥ��å������ޤ��� +�������������ФΥ��ɥ쥹������������ݡ����ֹ�Ǥ��� +�֥��å���Ȥ��� File.open ��Ʊ���褦�˽�ü������ưŪ�ˤ�äƤ���� +�ΤǤ�������Ǥ��� + + require 'net/smtp' + Net::SMTP.start( 'your.smtp.server', 25 ) {|smtp| + # use smtp object only in this block + } + +your.smtp.server ��Ŭ�ڤ� SMTP �����ФΥ��ɥ쥹���ɤߤ����Ƥ��������� +�̾�� LAN �δ����Ԥ�ץ��Х����� SMTP �����Ф��Ѱդ��Ƥ���Ƥ���Ϥ��Ǥ��� + +���å���������餢�Ȥ� send_mail �ǥ���ή����������Ǥ��� + + require 'net/smtp' + + Net::SMTP.start( 'your.smtp.server', 25 ) {|smtp| + smtp.send_mail <<EndOfMail, '[email protected]', '[email protected]' + From: Your Name <[email protected]> + To: Dest Address <[email protected]> + Subject: test mail + Date: Sat, 23 Jun 2001 16:26:43 +0900 + Message-Id: <[email protected]> + + This is test mail. + EndOfMail + } + +=== ���å�����λ���� + +�������ä��� SMTP#finish ��Ƥ�ǥ��å�����λ���ʤ���Ф��� +�ޤ���File �Τ褦�� GC ���˾���� close ����뤳�Ȥ⤢��ޤ��� +���������ʤȤ����� finish ���ʤ������������ɤ���ݤ��ޤ����� +���٤Ƹ���Ǥ���finish ��ɬ���Ƥ�Ǥ��������� + +�ޤ��֥��å��դ��� SMTP.start/SMTP#start ��Ȥ��Ⱦ���� finish �� +�Ƥ�Ǥ����Τ������Ǥ�����ǽ�ʸ¤�֥��å��դ��� start ��Ȥ��Τ� +�褤�Ǥ��礦�� + + # using SMTP#finish + smtp = Net::SMTP.start( 'your.smtp.server', 25 ) + smtp.send_mail mail_string, 'from@address', 'to@address' + smtp.finish + + # using block form of SMTP.start + Net::SMTP.start( 'your.smtp.server', 25 ) {|smtp| + smtp.send_mail mail_string, 'from@address', 'to@address' + } + +=== ʸ����ʳ���������� + +�ҤȤľ����Ǥ�ʸ�����ƥ��(�ҥ��ɥ������)��Ȥä��������ޤ������� +each ��åɤ���ä����֥������Ȥ���ʤ�ʤ�Ǥ����뤳�Ȥ��Ǥ��ޤ��� +�ʲ��� File ���֥������Ȥ���ľ������������Ǥ��� + + require 'net/smtp' + Net::SMTP.start( 'your.smtp.server', 25 ) {|smtp| + File.open( 'Mail/draft/1' ) {|f| + smtp.send_mail f, '[email protected]', '[email protected]' + } + } + +=== HELO �ɥᥤ�� + +SMTP �Ǥϥ�������¦�Υۥ��Ȥ�̾�� (HELO �ɥᥤ��ȸƤ�) ���� +�����ΤǤ�����Net::SMTP �ǤϤȤꤢ���� localhost.localdomain �� +����̾�����������Ƥ��ޤ��������Ƥ��� SMTP �����ФϤ��� HELO �ɥᥤ�� +�ˤ��ǧ�ڤϤ��ޤ꿿���ܤ˹Ԥ�ʤ��Τ� (��ñ�˵�¤�Ǥ��뤫��Ǥ�) +����ˤʤ�ʤ����Ȥ�¿���ΤǤ������ޤ�˥�륻�å������ڤ��� +���Ȥ⤢��ޤ������������Ȥ��ϤȤꤢ���� HELO �ɥᥤ���Ϳ���Ƥߤ� +�����������������ʳ��λ��� HELO �ɥᥤ��Ϥ������Ϥ��Τ� +�٥��ȤǤ��� + +HELO �ɥᥤ��� SMTP.start/SMTP#start ���軰���� helo_domain �˻��� +���ޤ��� + + Net::SMTP.start( 'your.smtp.server', 25, + 'mail.from.domain' ) {|smtp| + +�褯���������륢�åץۥ��Ȥξ�硢HELO �ɥᥤ��ˤ� ISP �Υ�� +�����ФΥɥᥤ���ȤäƤ����Ф����Ƥ��̤�ޤ��� + +== class Net::SMTP + +=== ���饹��å� + +: new( address, port = 25 ) + ������ SMTP ���֥������Ȥ��������ޤ���address ��SMTP�����С���FQDN�ǡ� + port ����³����ݡ����ֹ�Ǥ��������������Υ�åɤǤϤޤ���³�Ϥ��ޤ��� + +: start( address, port = 25, helo_domain = 'localhost.localdomain', account = nil, password = nil, authtype = nil ) +: start( address, port = 25, helo_domain = 'localhost.localdomain', account = nil, password = nil, authtype = nil ) {|smtp| .... } + �ʲ���Ʊ���Ǥ��� + Net::SMTP.new(address,port).start(helo_domain,account,password,authtype) + + # example + Net::SMTP.start( 'your.smtp.server' ) { + smtp.send_mail mail_string, '[email protected]', '[email protected]' + } + +=== ��å� + +: start( helo_domain = <local host name>, account = nil, password = nil, authtype = nil ) +: start( helo_domain = <local host name>, account = nil, password = nil, authtype = nil ) {|smtp| .... } + TCP ���ͥ�������ĥ�ꡢƱ���� SMTP ���å����Ϥ��ޤ������ΤȤ��� + ������Υۥ��Ȥ� FQDN �� helo_domain �˻��ꤷ�ޤ��� + �⤷���Ǥ˥��å�����Ϥ��Ƥ����� IOError ��ȯ�����ޤ��� + + account �� password ��ξ����Ϳ����줿��硢AUTH ���ޥ�ɤˤ�ä� + ǧ�ڤ�Ԥ��ޤ���authtype �ϻ��Ѥ���ǧ�ڤΥ����פǡ�����ܥ� + �� :plain �� :cram_md5 ����ꤷ�ޤ��� + +: active? + SMTP ���å�����Ϥ���Ƥ����鿿�� + +: address + ��³���륢�ɥ쥹 + +: port + ��³����ݡ����ֹ� + +: open_timeout +: open_timeout=(n) + ��³�����Ԥĺ����ÿ��������ÿ����äƤ⥳�ͥ������ + �����ʤ�����㳰 TimeoutError ��ȯ�����ޤ��� + +: read_timeout +: read_timeout=(n) + �ɤߤ��� (read(1) ���) �ǥ֥��å����Ƥ褤�����ÿ��� + �����ÿ����äƤ��ɤߤ���ʤ�����㳰 TimeoutError ��ȯ�����ޤ��� + +: finish + SMTP ���å�����λ���ޤ������å�������ˤ��Υ�åɤ� + �ƤФ줿�����㳰 IOError ��ȯ�����ޤ��� + +: send_mail( mailsrc, from_addr, *to_addrs ) + mailsrc ����Ȥ����������ޤ���mailsrc �� each ���ƥ졼������� + ���֥������Ȥʤ�ʤ�Ǥ���ޤ��� (���Ȥ��� String �� File)�� + from_domain �������Υ�륢�ɥ쥹 ('...@...'�Τ������Τ��) �ǡ� + to_addrs �ˤ��������륢�ɥ쥹���¤٤ޤ��� + + # example + Net::SMTP.start( 'your.smtp.server' ) {|smtp| + smtp.send_mail mail_string, + '[email protected]', + } + +: ready( from_addr, *to_addrs ) {|adapter| .... } + �����ߤν����������ǡ�write ��åɤ���ĥ��֥������Ȥ� + �֥��å��ˤ������ޤ���from_addr ����������륢�ɥ쥹�� to_addrs �� + ����Υ��ܥå����Ǥ��� + + # example + Net::SMTP.start( 'your.smtp.server', 25 ) {|smtp| + smtp.ready( '[email protected]', '[email protected]' ) {|f| + f.puts 'From: [email protected]' + f.puts 'To: [email protected]' + f.puts 'Subject: test mail' + f.puts + f.puts 'This is test mail.' + } + } + +== ȯ�������㳰 + +���å������� (SMTP ��٥��) ���顼�������ä���硢 +�ʲ����㳰��ȯ�����ޤ��� +: Net::ProtoSyntaxError + SMTP ���ޥ�ɤι�ʸ�ߥ�(500����) +: Net::ProtoFatalError + ����Ū�ʥ��顼(550����) +: Net::ProtoUnknownError + ͽ�����ʤ����顼�������餯�Х� +: Net::ProtoServerBusy + ���Ū�ʥ��顼(420/450����) + +=end |