Skip to content

Instantly share code, notes, and snippets.

@nkwhr
Created June 3, 2014 03:22
Show Gist options
  • Save nkwhr/cdac2999c0d32a6f4cdb to your computer and use it in GitHub Desktop.
Save nkwhr/cdac2999c0d32a6f4cdb to your computer and use it in GitHub Desktop.
Perlでメールを送るときのテンプレート
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Email::Sender::Simple qw/sendmail/;
use Email::MIME;
use Encode;
my $email = Email::MIME->create(
header => [
From => encode('MIME-Header-ISO_2022_JP' => '"Me" <[email protected]>'),
To => encode('MIME-Header-ISO_2022_JP' => '"You" <[email protected]>'),
Subject => encode('MIME-Header-ISO_2022_JP' => '件名'),
],
attributes => {
content_type => 'text/plain',
charset => 'ISO-2022-JP',
encoding => '7bit',
},
body => encode('iso-2022-jp' => '本文'),
);
my $email_utf8 = Email::MIME->create(
header_str => [
From => '[email protected]',
To => '[email protected]',
Subject => '件名',
],
attributes => {
content_type => 'text/plain',
charset => 'UTF-8',
encoding => 'base64',
},
body_str => '本文',
);
sendmail($email);
sendmail($email_utf8);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment