* メール送信 [#f0579227]
// -----------------------------------------------------------------------------
// メール送信
// -----------------------------------------------------------------------------
function send_mail($data) {
$body = $data['body'];
$subject = $data['subject'];
$from = $data['from'];
$to = $data['to'];
$from_name = $data['from_name'];
$orig_enc = mb_internal_encoding();
mb_internal_encoding('ISO-2022-JP');
$subject = mb_convert_encoding($subject,'ISO-2022-JP',$orig_enc);
$subject = mb_encode_mimeheader($subject,'ISO-2022-JP');
$headers = '';
$from = sprintf('%s<%s>',
mb_encode_mimeheader (mb_convert_encoding($from_name,'ISO-2022-JP',$orig_enc),'ISO-2022-JP'),
$from
);
mb_internal_encoding($orig_enc);
$headers .= "From: $from\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/plain;charset=\"ISO-2022-JP\"\n";
$headers .= "Content-Transfer-Encoding: 7bit\n";
if (!is_array($to)) $to = array($to);
foreach ($to as $t) {
$result = mail($t,$subject,mb_convert_encoding(trim($body),'ISO-2022-JP',$orig_enc),$headers);
if (!$result) {
throw new Exception('メール送信に失敗しました:'.$t);
}
}
}