Yanor.net/
Wiki
Blog
GitHub
Sandbox
開始行:
* デコメール送信(Perl) [#vf590ab8]
** マルチパートの構成 [#bc4ec4fb]
*** ドコモ [#ic37c710]
multipart/mixed
├ multipart/related
│├ multipart/alternative
││├ text/plain
││└ text/html
│└ image/gif # インライン画像
└ image/gif # 添付画像
*** AU [#w6a91401]
multipart/mixed
├ multipart/alternative
│├ text/plain
│└ text/html
└ image/gif
- 添付画像は不可?
*** ソフトバンク [#v6f9ada7]
multipart/related
├ multipart/alternative
│├ text/plain
│└ text/html
└ image/gif # インライン画像兼添付画像?
- デコメール携帯4社MIMEマルチパート比較 http://www.cpa-la...
** サンプルコード [#hffe2c38]
use utf8;
use Encode;
use Encode::JP::Mobile;
use Mail::Address::MobileJp;
use MIME::Lite;
use HTML::Scrubber;
use MIME::Base64;
use Path::Class;
my $email_from = 'taro@example.net';
my $email_to = 'hanako@ezweb.ne.jp';
my $emoji_bytes = "\xF8\x9F"; # ドコモのSJISコード「太...
my $emoji_chars = decode( 'x-sjis-imode', $emoji_bytes );
my $subject = "件名です";
my $html = <<"END";
<html>
<body>
<font color="#FF0000"><a href="http://portal.mobile.yaho...
$emoji_chars<br>
<img src="cid:my\@image">
</body>
</html>
END
my $text = HTML::Scrubber->new->scrub($html);
my $subject_encoded =
is_imode($email_to)
? '=?SHIFT-JIS?B?' . MIME::Base64::encode( encode( 'x-...
: is_softbank($email_to)
? '=?UTF-8?B?' . MIME::Base64::encode( encode( 'x-utf8...
: is_ezweb($email_to) ? encode( 'x-sjis-kddi-auto', $s...
: '=?ISO-2022-JP?B?' . MIME::Bas...
my $html_encoded =
is_imode($email_to) ? encode( 'x-sjis-docomo', ...
: is_softbank($email_to) ? encode( 'x-utf8-softbank', ...
: is_ezweb($email_to) ? encode( 'x-sjis-kddi-auto',...
: encode( 'iso-2022-jp', $htm...
my $text_encoded =
is_imode($email_to) ? encode( 'x-sjis-docomo', ...
: is_softbank($email_to) ? encode( 'x-utf8-softbank', ...
: is_ezweb($email_to) ? encode( 'x-sjis-kddi-auto',...
: encode( 'iso-2022-jp', $tex...
my $alternative = MIME::Lite->new( Type => 'multipart/al...
$alternative->attach(
Type => 'text/html',
Data => $html_encoded,
Encoding => '8bit',
);
$alternative->attach(
Type => 'text/plain',
Data => $text_encoded,
Encoding => '8bit',
);
my $image = MIME::Lite->new(
Type => 'image/gif; name="image.gif"',
Id => '<my@image>',
Data => scalar file( '.', 'image.gif' )->slurp,
Encoding => 'base64',
);
if ( is_imode() ) {
my $related = MIME::Lite->new( Type => 'multipart/re...
$related->attach($alternative);
$related->attach($image);
my $mixed = MIME::Lite->new(
Type => 'multipart/mixed',
Subject => $subject_encoded,
From => $email_from,
To => $email_to,
);
my $image2 = MIME::Lite->new(
Type => 'image/gif; name="image.gif"',
Data => scalar file( '.', 'image.gif' )->slu...
Encoding => 'base64',
);
$mixed->attach($image2);
$mixed->attach($related);
$mixed->send;
}
elsif (is_ezweb) {
my $mixed = MIME::Lite->new(
Type => 'multipart/mixed',
Subject => $subject_encoded,
From => $email_from,
To => $email_to,
);
$mixed->attach($alternative);
$mixed->attach($image);
$mixed->send;
}
elsif (is_softbank || 1) {
my $related = MIME::Lite->new(
Type => 'multipart/related',
Subject => $subject_encoded,
From => $email_from,
To => $email_to,
);
$related->attach($alternative);
$related->attach($image);
$related->send;
}
- AUの場合、Contents-IDは"@"を1つだけ含まなければならない...
** 参考 [#dfc76b95]
- デコメール携帯4社MIMEマルチパート比較 http://www.cpa-la...
- 開封率の高いデコメールでメルマガ配信! http://thinkit.j...
- Perlを使ったドコモデコメールの実例 http://codezine.jp/a...
*** キャリア公式 [#w4a8571d]
-ドコモ http://www.nttdocomo.co.jp/service/imode/make/con...
-- MIMEフォーマットについて http://www.nttdocomo.co.jp/se...
- AU http://www.au.kddi.com/ezfactory/tec/spec/decoration...
- ソフトバンク http://mb.softbank.jp/mb/service/3G/mail/a...
*** CPAN [#meae4c2f]
- MIME::Lite http://search.cpan.org/perldoc?MIME::Lite
- Encode::JP::Mobile http://search.cpan.org/perldoc?Encod...
- Encode::JP::Mobile::Cookbook http://search.cpan.org/per...
終了行:
* デコメール送信(Perl) [#vf590ab8]
** マルチパートの構成 [#bc4ec4fb]
*** ドコモ [#ic37c710]
multipart/mixed
├ multipart/related
│├ multipart/alternative
││├ text/plain
││└ text/html
│└ image/gif # インライン画像
└ image/gif # 添付画像
*** AU [#w6a91401]
multipart/mixed
├ multipart/alternative
│├ text/plain
│└ text/html
└ image/gif
- 添付画像は不可?
*** ソフトバンク [#v6f9ada7]
multipart/related
├ multipart/alternative
│├ text/plain
│└ text/html
└ image/gif # インライン画像兼添付画像?
- デコメール携帯4社MIMEマルチパート比較 http://www.cpa-la...
** サンプルコード [#hffe2c38]
use utf8;
use Encode;
use Encode::JP::Mobile;
use Mail::Address::MobileJp;
use MIME::Lite;
use HTML::Scrubber;
use MIME::Base64;
use Path::Class;
my $email_from = 'taro@example.net';
my $email_to = 'hanako@ezweb.ne.jp';
my $emoji_bytes = "\xF8\x9F"; # ドコモのSJISコード「太...
my $emoji_chars = decode( 'x-sjis-imode', $emoji_bytes );
my $subject = "件名です";
my $html = <<"END";
<html>
<body>
<font color="#FF0000"><a href="http://portal.mobile.yaho...
$emoji_chars<br>
<img src="cid:my\@image">
</body>
</html>
END
my $text = HTML::Scrubber->new->scrub($html);
my $subject_encoded =
is_imode($email_to)
? '=?SHIFT-JIS?B?' . MIME::Base64::encode( encode( 'x-...
: is_softbank($email_to)
? '=?UTF-8?B?' . MIME::Base64::encode( encode( 'x-utf8...
: is_ezweb($email_to) ? encode( 'x-sjis-kddi-auto', $s...
: '=?ISO-2022-JP?B?' . MIME::Bas...
my $html_encoded =
is_imode($email_to) ? encode( 'x-sjis-docomo', ...
: is_softbank($email_to) ? encode( 'x-utf8-softbank', ...
: is_ezweb($email_to) ? encode( 'x-sjis-kddi-auto',...
: encode( 'iso-2022-jp', $htm...
my $text_encoded =
is_imode($email_to) ? encode( 'x-sjis-docomo', ...
: is_softbank($email_to) ? encode( 'x-utf8-softbank', ...
: is_ezweb($email_to) ? encode( 'x-sjis-kddi-auto',...
: encode( 'iso-2022-jp', $tex...
my $alternative = MIME::Lite->new( Type => 'multipart/al...
$alternative->attach(
Type => 'text/html',
Data => $html_encoded,
Encoding => '8bit',
);
$alternative->attach(
Type => 'text/plain',
Data => $text_encoded,
Encoding => '8bit',
);
my $image = MIME::Lite->new(
Type => 'image/gif; name="image.gif"',
Id => '<my@image>',
Data => scalar file( '.', 'image.gif' )->slurp,
Encoding => 'base64',
);
if ( is_imode() ) {
my $related = MIME::Lite->new( Type => 'multipart/re...
$related->attach($alternative);
$related->attach($image);
my $mixed = MIME::Lite->new(
Type => 'multipart/mixed',
Subject => $subject_encoded,
From => $email_from,
To => $email_to,
);
my $image2 = MIME::Lite->new(
Type => 'image/gif; name="image.gif"',
Data => scalar file( '.', 'image.gif' )->slu...
Encoding => 'base64',
);
$mixed->attach($image2);
$mixed->attach($related);
$mixed->send;
}
elsif (is_ezweb) {
my $mixed = MIME::Lite->new(
Type => 'multipart/mixed',
Subject => $subject_encoded,
From => $email_from,
To => $email_to,
);
$mixed->attach($alternative);
$mixed->attach($image);
$mixed->send;
}
elsif (is_softbank || 1) {
my $related = MIME::Lite->new(
Type => 'multipart/related',
Subject => $subject_encoded,
From => $email_from,
To => $email_to,
);
$related->attach($alternative);
$related->attach($image);
$related->send;
}
- AUの場合、Contents-IDは"@"を1つだけ含まなければならない...
** 参考 [#dfc76b95]
- デコメール携帯4社MIMEマルチパート比較 http://www.cpa-la...
- 開封率の高いデコメールでメルマガ配信! http://thinkit.j...
- Perlを使ったドコモデコメールの実例 http://codezine.jp/a...
*** キャリア公式 [#w4a8571d]
-ドコモ http://www.nttdocomo.co.jp/service/imode/make/con...
-- MIMEフォーマットについて http://www.nttdocomo.co.jp/se...
- AU http://www.au.kddi.com/ezfactory/tec/spec/decoration...
- ソフトバンク http://mb.softbank.jp/mb/service/3G/mail/a...
*** CPAN [#meae4c2f]
- MIME::Lite http://search.cpan.org/perldoc?MIME::Lite
- Encode::JP::Mobile http://search.cpan.org/perldoc?Encod...
- Encode::JP::Mobile::Cookbook http://search.cpan.org/per...
ページ名: