Perlでメールを投げる

  • 文字コードは iso-2022-jp

SMTP の設定例

export EMAIL_SENDER_TRANSPORT=SMTP
export EMAIL_SENDER_TRANSPORT_host=smtp.example.com
export EMAIL_SENDER_TRANSPORT_port=1025

サンプルコード

use strict;
use Email::MIME;
use Email::MIME::Creator;
use Email::Sender::Simple qw(sendmail);
my $subject = Encode::encode('MIME-Header-ISO_2022_JP', 'さぶじぇくと');
my $mail = Email::MIME->create( 'header' => [ 'From' => Encode::encode('MIME-Header-ISO_2022_JP', 'foo@example.com'), 'To' => Encode::encode('MIME-Header-ISO_2022_JP', 'to@example.com'), 'Subject' => $subject, ], 'attributes' => { 'content_type' => 'text/plain', 'charset' => 'ISO-2022-JP', 'encoding' => '7bit', }, 'body' => Encode::encode('iso-2022-jp', 'ほんぶん!'),
);