milano氏の情報を元に書いてみました。
以下のラーメンのエントリーのように表示されます。
タイトル:ラーメン
本文:喜多方
添付:しゃしん
ez携帯からメール
#!/usr/bin/perl
use strict;
use MIME::Parser;
use MIME::WordDecoder;
use Image::Magick;
use Time::Piece;
use Jcode;
use DBI;
my $t = localtime;
my $outputdir= '/home/www.de4u.net/htdocs/img/photo';
my $imgpath = '/img/photo';
my $parser = new MIME::Parser;
$parser->output_under('/tmp/photo');
my $entity = $parser->parse(\*STDIN) or die;
my ($mail_body, $filename);
# HEAD
my $mail_from = $entity->head->get('from');
my $mail_date = $entity->head->get('date');
my $mail_subject = $entity->head->get('subject');
if ($entity->is_multipart){
my $count = $entity->parts;
for (my $i = 0; $i < $count; $i++) {
# text or binary
my ($type, $subtype) = split('/', $entity->parts($i)->head->mime_type);
if ($type =~ /^(text|message)$/) { # text
$mail_body .= $entity->parts($i)->bodyhandle->as_string;
} else {
$filename= $t->ymd('') . $t->hms('') . '.png';
my $image = Image::Magick->new(magick=>'bmp');
$image->BlobToImage($entity->parts($i)->bodyhandle->as_string);
$image->Write("$outputdir/$filename");
chmod(0644, "$outputdir/$filename");
}
}
}
# decode to euc
$mail_subject = Jcode->new($mail_subject)->mime_decode->euc;
$mail_body = Jcode->new($mail_body)->euc;
# make blog entry
my $entry = qq(\n);
$entry .= $mail_body;
my $title = $mail_subject;
# データソース
my $dsn = 'DBI:mysql:DBNAME';
# ユーザ名
my $user = 'USER';
# パスワード
my $password = 'PASSWD';
# データベースへ接続
my $dbh = DBI->connect($dsn, $user, $password,
{ RaiseError => 1, AutoCommit => 0 });
my $sql = qq(insert into mt_entry values (NULL,1,2,1,1,NULL,1,NULL,?,'',?,'','',NULL,NULL,NULL,now(),now()\
,NULL,NULL));
$dbh->do($sql, undef, $title, $entry);
$dbh->disconnect();

コメント (1)
はやいですねーPOPですー
うちもがんばってみます
わからいこと教えてください
SWFの外部読み込みでスライドショーにしたいです
30枚 31万画素のLOOPで
BGMは NETRADIOで
イベントでまえ ありましたねなんか
投稿者: mpm | 2002年12月 5日 18:43
日時: 2002年12月 5日 18:43