- 追加された行はこの色です。
- 削除された行はこの色です。
* Email-Senderによるメール送信 [#j3cd4e5f]
スクリプトはEUC-JPで保存する事とする。
#!/usr/bin/env perl
use strict;
use warnings;
use Email::Sender::Simple qw(sendmail);
use Email::Simple;
use Email::Simple::Creator;
use Encode qw/from_to/;
my $from_name = '名前';
my $from_email = 'saburo@example.net';
my $subject = '件名';
my $body = '本文';
my @to_emails = ( 'taro@example.com', 'jiro@example.co.jp' );
my $_from_email = sprintf( '%s <%s>', $from_name, $from_email );
from_to( $_from_email, 'euc-jp', 'MIME-Header-ISO_2022_JP' );
from_to( $subject, 'euc-jp', 'MIME-Header-ISO_2022_JP' );
from_to( $body, 'euc-jp', 'iso-2022-jp' );
foreach my $to_email (@to_emails) {
my $email = Email::Simple->create(
header => [
To => $to_email,
From => $_from_email,
Subject => $subject,
],
body => $body,
attributes => {
content_type => 'text/plain',
charset => 'ISO-2022-JP',
encoding => '7bit',
},
);
sendmail($email);
}