Ads by Google
新しい記事を書く事で広告が消せます。
株式会社AnySenseで働く開発者の殴り書き
<?PHP
$this_dir = dirname(__FILE__);
require_once('Mail_mime_Decomail.php');
$mime = new Mail_Mime_Decomail();
mb_language('ja');
mb_internal_encoding('UTF-8');//このスクリプトの文字コード(適宜変更して下さい)
//HTML本文
$html_body = '<html><body>福岡のモバイル開発会社エニセンスの開発者ブログです。<img src="cid:001@any-sense"></body></html>';
//テキスト本文
$text_body = '福岡のモバイル開発会社エニセンスの開発者ブログです。';
//文字エンコーディングをJISに変更(スクリプトの文字コードがUTF-8でなければ適宜変更)
$html_body = mb_convert_encoding($html_body, 'JIS', 'UTF-8');
$text_body = mb_convert_encoding($text_body, 'JIS', 'UTF-8');
$mime->setTXTBody($text_body);
$mime->setHTMLBody($html_body);
//インライン画像(画像の数だけ繰り返す。cidは毎回変える必要あり)
$img_file = 'hogehoge.gif';
$content_type = 'image/gif';
$img_name = basename($img_file);
$cid = '001@any-sense'; //Content-IDを指定(@マークを含ませる)
$mime->addHTMLImage($img_file, $content_type, $img_name, true, $cid);
//Subject
$subject = '件名';
$subject = mb_encode_mimeheader($subject, 'JIS');
//From
$from = 'from@hoge.hoge';
$mime->setFrom($from);
//To
$to = 'to@hoge.hoge';
$buid_params = array(
'head_encoding' => 'base64',
'text_encoding' => '7bit',
'html_encoding' => 'quoted-printable',
'7bit_wrap' => 998,
'html_charset' => 'ISO-2022-JP',
'text_charset' => 'ISO-2022-JP',
'head_charset' => 'ISO-2022-JP'
);
$body = $mime->get($buid_params);
$hdrs = $mime->headers($hdrs);
$header = '';
foreach($hdrs as $name => $value){
$header .= $name.': '.$value."\r\n";
}
mail($to , $subject , $body, $header);
?>
comment