GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Email::MIME::Creator::ISO_2022_JP(3) User Contributed Perl Documentation Email::MIME::Creator::ISO_2022_JP(3)
 

Email::MIME::Creator::ISO_2022_JP - Email::MIME mixin to create an iso-2022-jp mail

  use Email::Sender::Simple 'sendmail';
  use Email::MIME;
  use Email::MIME::Creator::ISO_2022_JP;
  use utf8;
  
  my $email_jis = Email::MIME->create(
    header_str => [
      From    => 'foo@example.com',
      To      => 'bar@example.com',
      Subject => 'こんにちは',
    ],
    attributes => {
      content_type => 'text/plain',
      charset      => 'iso-2022-jp',
      encoding     => '7bit',
    },
    body_str => 'メールの本文はutf-8で',
  );
  
  sendmail($email_jis);  # in iso-2022-jp
  
  no Email::MIME::Creator::ISO_2022_JP;
  
  my $email_utf8 = Email::MIME->create(
    header_str => [
      From    => 'foo@example.com',
      To      => 'bar@example.com',
      Subject => 'こんにちは',
    ],
    attributes => {
      content_type => 'text/plain',
      charset      => 'utf-8',
      encoding     => '7bit',
    },
    body_str => 'メールの本文はutf-8で',
  );
  
  sendmail($email_utf8);  # in utf-8

Email::MIME is nice and handy. With "header_str" and "body_str" (since 1.900), you don't need to encode everything by yourself. Just pass flagged ("decode"d) utf-8 strings, and you'll get what you want. However, it only works when you send utf-8 encoded emails. In Japan, there're still some email clients that only understand iso-2022-jp (jis) encoded emails, and its popularity persuaded the Encode maintainer (who's also Japanese) to include its support (since version 2.11, with "Encode::MIME::Header::ISO_2022_JP" written by Makamaka). I want it to be supported by Email::MIME, but it's too specific and nonsense for the rest of the world. That's why I write this mixin instead of asking to add extra bit to Email::MIME.
As of this writing, this mixin doesn't care the tangled issues in the Japanese cellular phone industry (thus not "::Japanese"). If you need finer control, just use "header"/"body" and encoded string/octets, or send me a patch.

Both work almost the same as Email::MIME's methods do, with one exception. If you pass utf-8 stings to "header_str" attribute or "header_str_set" method, they'll be encoded by "Encode::MIME::Header::ISO_2022_JP", instead of "Encode::MIME::Header".

Actually you don't need to use these directly. As shown in the SYNOPSIS, when this module is "use"d, Email::MIME's original "create" and "header_str_set" are replaced with these methods internally. If you want to use the orignal methods again, unimport this module (with "no" pragma, or "unimport" method), and they'll be restored.

As a bonus, this module eliminates "Date" and "MIME-Version" headers from each part in a multipart email.

Email::MIME, Encode

Kenichi Ishigaki, <ishigaki@cpan.org>

Copyright (C) 2009 by Kenichi Ishigaki.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2009-11-06 perl v5.28.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.