PHP メールを送る
クラスにするまでもないのですが。
使い回しがききそうなので。
class SendMail{
/*インスタンス作成時の引数は配列
$option=array(
"to"=>test@test.com,
"subject"=>"タイトル",
"body"=>"本文",
"from_name"=>"送信者",
"from_email"=>"form@test.com"
);
*/
function __construct($option){
$this->encoding="utf-8";
mb_language("ja");
mb_internal_encoding($this->encoding);
$this->option=$option;
}
function mimeHeader($str){
return mb_encode_mimeheader (mb_convert_encoding($str,"ISO-2022-JP",$this->encoding));
}
function send(){
extract($this->option);
$f_from_name=$this->mimeHeader($from_name);
$headers = "MIME-Version: 1.0 \n From: {$f_from_name}<{$from_email}> \n";
if($reply=="true") $headers .= "Reply-To: {$f_from_name} <{$from_email}> \n";
$headers .= "Content-Type: text/plain;charset=ISO-2022-JP \n";
$subject =$this->mimeHeader($subject);
$body = mb_convert_encoding($body, "ISO-2022-JP", $this->encoding);
$sendmail_params = "-f$from_email";
$result = mail($to, $subject, $body, $headers, $sendmail_params);
return $result;
}
}
関連記事
- PHP メールを送る
- PHP mail()の関数変更
- PHP メールアドレスの書式チェック
- PHP unix ディレクトリの通常ファイル個数を調べる
- Yahoo YUIでWYSIWYG
- HTML5 canvas一歩め
- PHP phpファイルをcssで出力
- Tweener addCallでタイマーの代わりに使ってみたい
- swfobject2 第2回
- MDB2 結果の行数取得numRows()
- jQuery チェックボックスのチェック・解除
- MDB2 データ取得
- AS3 TweenerのsetTimeScaleを試すつもりが
- jQuery 使えそうなサンプル
- jQuery submitでconfirm