2005-08 / 2005-08-20

前のエントリ: NTPを使ってマシンの時刻合わせ [debian]
次のエントリ: alternativesアプリの変更 [debian]

SMTPでNULL(0x00)文字を送信する
2005-08-20-2 / カテゴリ: [programming][perl][SMTP] / [permlink]

MUA(メーラ)や telnet じゃちょっと無理だけど、プログラム書いちゃえば簡単。
Net::SMTP, Mail::Sender, Mail::Sendmail の3つを試したが、どれも送信可能。RFC的にはコントロールコードを含むascii文字を送信して良いと読めるので、MTAは処理しなければならない…と思う。少なくとも、MTA が core 吐いて死んだりとかは NG でしょう。

RFC2821 4.5.2 Transparency より引用
   The mail data may contain any of the 128 ASCII characters. All
   characters are to be delivered to the recipient's mailbox, including
   spaces, vertical and horizontal tabs, and other control characters.

Net::SMTP版
use Net::SMTP;
$smtp = Net::SMTP->new("localhost",
                       Debug => 1) or die;
$smtp->mail('from@mail.example.org');
$smtp->to('to@mail.example.org');
$smtp->data();
$smtp->datasend("\x1\x0\x1");
$smtp->dataend();
$smtp->quit();

Mail::Sender版
use Mail::Sender;
$sender = new Mail::Sender{smtp => 'localhost',
                           from => 'from@mail.example.org'};
$sender->MailMsg({ to => 'to@mail.example.org',
                   msg => "\x1\x0\x1" });

Mail::Sendmail版
use Mail::Sendmail;
$Mail::Sendmail::mailcfg{mime} = 0;
sendmail( To => 'to@mail.example.org',
          From => 'from@mail.example.org',
          Message => "\x1\x0\x1" ) or die $Mail::Sendmail::error;

Mail::Sender は、デフォルトでは(MIME::QuotedPrintが使えれば)quoted-print エンコードして送信するので、mailcfg{mime} を false に設定する。
前のエントリ: NTPを使ってマシンの時刻合わせ [debian]
次のエントリ: alternativesアプリの変更 [debian]

2013 : 01 02 03 04 05 06 07 08 09 10 11 12
2012 : 01 02 03 04 05 06 07 08 09 10 11 12
2011 : 01 02 03 04 05 06 07 08 09 10 11 12
2010 : 01 02 03 04 05 06 07 08 09 10 11 12
2009 : 01 02 03 04 05 06 07 08 09 10 11 12
2008 : 01 02 03 04 05 06 07 08 09 10 11 12
2007 : 01 02 03 04 05 06 07 08 09 10 11 12
2006 : 01 02 03 04 05 06 07 08 09 10 11 12
2005 : 01 02 03 04 05 06 07 08 09 10 11 12
2004 : 01 02 03 04 05 06 07 08 09 10 11 12

最終更新時間: 2013-05-02 16:12