ã¯ããã«
ãè¥ãä¸ä»£ã®å¥³æ§ãä¸å¿ã«ãã³ã¡ã¼ã«ã注ç®ããã¦ãã¾ãã
ããã³ã¡ã¼ã«ã¨ã¯NTTãã³ã¢ã®FOMA900iã·ãªã¼ãºããå°å ¥ãããç°¡æHTMLã¡ã¼ã«æ©è½ã§ãHTMLã¡ã¼ã«ãªãã§ã¯ã®æå修飾ãç»åã®åãè¾¼ã¿ãªã©ãå¯è½ã§ãããããã®æ©è½ã使ãã°ããã ã®ããã¹ãã®ã¡ã¼ã«ãããåæ§çã§ããããã¡ã¼ã«ãéããã¨ãã§ããã®ã§ãããã人æ°ã«ã¤ãªãã£ã¦ããããã§ãã
ããã³ã¡ã¼ã«ã®ä»æ§ã¯ä¸è¨ã§å ¬éããã¦ãã¾ãã
- NTTãã³ã¢ ãä½ããiã¢ã¼ãã³ã³ãã³ãï¼ãã³ã¡ã¼ã«ã
ãæ¬ç¨¿ã§ã¯CPANã¢ã¸ã¥ã¼ã«ã®MIME::Liteã使ã£ããµã³ãã«ãç¨ãã¦ããã³ã¡ã¼ã«ã®åºæ¬çãªä»æ§ã«ã¤ãã¦è§£èª¬ãã¾ãã
ãâ»CPANã«ã¤ãã¦ã¯ã第1åãåç §ãã¦ãã ããã
対象èªè
- Perlã§CGIã¢ããªã±ã¼ã·ã§ã³ãä½æãããã¨ã®ããæ¹ã
- CPANã¢ã¸ã¥ã¼ã«ã使ç¨ãããã¨ã®ããæ¹ã
- æºå¸¯ãµã¤ãã§ãã³ã¡ã¼ã«ãé ä¿¡ãããã¨ããã¦ããæ¹ã
å¿ è¦ãªç°å¢
ãPerl 5.8以ä¸ãåä½ããã¡ã¼ã«ãéä¿¡ãããã¨ãã§ãããµã¼ãã
ãã³ã¡ã¼ã«ã®ãã¿ã¼ã³
ã大ããåãã¦ãã³ã¡ã¼ã«ã«ã¯ã以ä¸ã®4ã¤ã®ãã¿ã¼ã³ãããã¾ãã
- HTMLã®ã¿
HTMLã®ã¿ãéä¿¡ãããã¿ã¼ã³ã§ãã
- HTMLï¼ç»åæ·»ä»
HTMLã«ä½µãã¦ç»åãæ·»ä»ãããã¿ã¼ã³ã§ãã
- HTMLï¼ã¤ã³ã©ã¤ã³ç»å
HTMLå ã«ç»åãã¤ã³ã©ã¤ã³è¡¨ç¤ºããããã¿ã¼ã³ã§ãã
- ãã³ã¡ã¼ã«ãã³ãã¬ã¼ã
ãã³ã¡ã¼ã«ãã³ãã¬ã¼ãã¨å¼ã°ãããã³ã¡ã¼ã«ã®éå½¢ãæ±ããã¿ã¼ã³ã§ããã¦ã¼ã¶ã¼ã¯ããã®ãã³ãã¬ã¼ããç·¨éãã¦éä¿¡ãããã¨ãã§ãã¾ãã
ãããã§ã¯ãããã4ã¤ã®ãã¿ã¼ã³ã«ã¤ãã¦ããµã³ãã«ã¨ä½µãã¦è¦ã¦ããã¾ãããã
HTMLã®ã¿
ãHTMLã®ã¿ã®MIMEãã©ã¼ãããã¯ä¸è¨ã®ããã«ãªãã¾ãã
ãContent-Typeãmultipart/alternativeã¨ãã¦ãTEXTãã¼ãã¨HTMLãã¼ããéä¿¡ãã¾ãããã³ã¡ã¼ã«é対å¿ç«¯æ«ã«ã¯ãTEXTãã¼ãã®ã¿éä¿¡ããããã¨ã«ãªãã¾ãã®ã§ãå¿ ãTEXTãã¼ããã¤ããããã«ãã¾ãããã
#!/usr/local/bin/perl use strict; use MIME::Lite; use Jcode; my $text = 'ãèªçæ¥ããã§ã¨ã'; my $html = <<''; <html> <body> <font color="#FF0000">ãèªçæ¥ããã§ã¨ã</font> </body> </html> my $msg = MIME::Lite->new( Type => 'multipart/alternative', Subject => 'Happy Birthday!!', From => 'éä¿¡å ã¢ãã¬ã¹', To => 'éä¿¡å ã¢ãã¬ã¹', Encoding => '8bit', ); # HTMLãã¼ãï¼å¯¾å¿ç«¯æ«ã«éä¿¡ãããé¨åï¼ $msg->attach( Type => 'text/html', Data => Jcode->new($html)->sjis, Encoding => '8bit', ); # TEXTãã¼ãï¼é対å¿ç«¯æ«ã«éä¿¡ãããé¨åï¼ $msg->attach( Type => 'text/plain', Data => $text, Encoding => '8bit', ); $msg->send;
HTMLï¼ç»åæ·»ä»
ãç»åãæ·»ä»ããå ´åã¯ãä¸è¨ã®ãããªMIMEãã©ã¼ãããã«ãªãã¾ãï¼GIFãã¡ã¤ã«ãæ·»ä»ããä¾ã§ãï¼ã
ãContent-Typeã¯multipart/mixedã§éä¿¡ãã¾ããæ·»ä»ãã¡ã¤ã«ã¯ãGIFã»JPGã»SWFãã¡ã¤ã«ãå©ç¨ã§ãã¾ãã
#!/usr/local/bin/perl use strict; use MIME::Lite; use Jcode; use Path::Class; my $text = 'ãèªçæ¥ããã§ã¨ã'; my $html = <<''; <html> <body> <font color="#FF0000">ãèªçæ¥ããã§ã¨ã</font> </body> </html> my $body = MIME::Lite->new( Type => 'multipart/alternative', ); $body->attach( Type => 'text/plain', Data => $text, Encoding => '8bit', ); $body->attach( Type => 'text/html', Data => Jcode->new($html)->sjis, Encoding => '8bit', ); # æ·»ä»ããç»åãã¡ã¤ã«ï¼base64ã§ã¨ã³ã³ã¼ãï¼ my $image = MIME::Lite->new( Type => 'image/gif; name="cake"', Data => scalar file('.', 'cake.gif')->slurp, Encoding => 'base64', ); my $msg = MIME::Lite->new( Type => 'multipart/mixed', Subject => 'Happy Birthday!!', From => 'éä¿¡å ã¢ãã¬ã¹', To => 'éä¿¡å ã¢ãã¬ã¹', Encoding => '8bit', ); $msg->attach($body); $msg->attach($image); $msg->send;