1 | <?php |
---|
2 | /* |
---|
3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
---|
4 | * |
---|
5 | * http://www.lockon.co.jp/ |
---|
6 | */ |
---|
7 | |
---|
8 | //--- テキスト/HTML メール送信 |
---|
9 | class GC_SendMail { |
---|
10 | |
---|
11 | var $html; // HTML メールヘッダー |
---|
12 | var $to; // 送信先 |
---|
13 | var $subject; // 題名 |
---|
14 | var $body; // 本文 |
---|
15 | var $header; // ヘッダー |
---|
16 | var $return_path; // return path |
---|
17 | var $mailer; |
---|
18 | |
---|
19 | /* ヘッダ等を格納 |
---|
20 | $to -> 送信先メールアドレス |
---|
21 | $subject -> メールのタイトル |
---|
22 | $body -> メール本文 |
---|
23 | $fromaddress -> 送信元のメールアドレス |
---|
24 | $header -> ヘッダー |
---|
25 | $from_name -> 送信元の名前(全角OK) |
---|
26 | $reply_to -> reply_to設定 |
---|
27 | $return_path -> return-pathアドレス設定(エラーメール返送用) |
---|
28 | $cc -> カーボンコピー |
---|
29 | $bcc -> ブラインドカーボンコピー |
---|
30 | */ |
---|
31 | |
---|
32 | |
---|
33 | function setTo($to, $to_name = "") { |
---|
34 | if($to_name != "") { |
---|
35 | $name = ereg_replace("<","<", $to_name); |
---|
36 | $name = ereg_replace(">",">", $name); |
---|
37 | $name = mb_encode_mimeheader(mb_convert_encoding($name, "JIS", CHAR_CODE)); |
---|
38 | $this->to = $name . "<" . $to . ">"; |
---|
39 | } else { |
---|
40 | $this->to = $to; |
---|
41 | } |
---|
42 | } |
---|
43 | |
---|
44 | function setItem( $to, $subject, $body, $fromaddress, $from_name, $reply_to, $return_path, $errors_to="", $bcc="", $cc ="" ) { |
---|
45 | |
---|
46 | $this->to = $to; |
---|
47 | $this->subject = $subject; |
---|
48 | |
---|
49 | // iso-2022-jpだと特殊文字が?で送信されるのでJISを使用する。 |
---|
50 | $this->body = mb_convert_encoding( $body, "JIS", CHAR_CODE); |
---|
51 | |
---|
52 | // ヘッダーに日本語を使用する場合はMb_encode_mimeheaderでエンコードする。 |
---|
53 | $from_name = ereg_replace("<","<", $from_name); |
---|
54 | $from_name = ereg_replace(">",">", $from_name); |
---|
55 | $from_name = mb_convert_encoding($from_name,"JIS",CHAR_CODE); |
---|
56 | $this->header = "From: ". Mb_encode_mimeheader( $from_name )."<".$fromaddress.">\n"; |
---|
57 | $this->header .= "Reply-To: ". $reply_to . "\n"; |
---|
58 | $this->header .= "Cc: " . $cc. "\n"; |
---|
59 | $this->header .= "Bcc: " . $bcc . "\n"; |
---|
60 | $this->header .= "Errors-To: ". $errors_to ."\n"; |
---|
61 | |
---|
62 | $this->return_path = $return_path; |
---|
63 | } |
---|
64 | |
---|
65 | function setItemHtml( $to, $subject, $body, $fromaddress, $from_name, $reply_to, $return_path, $errors_to="", $bcc="", $cc ="" ) { |
---|
66 | |
---|
67 | $this->to = $to; |
---|
68 | $this->subject = mb_encode_mimeheader($subject); |
---|
69 | $this->body = mb_convert_encoding( $body, "JIS", CHAR_CODE); |
---|
70 | $this->header = "Mime-Version: 1.0\n"; |
---|
71 | $this->header .= "Content-Type: text/html; charset=iso-2022-jp\n"; |
---|
72 | $this->header .= "Content-Transfer-Encoding: 7bit\n"; |
---|
73 | $this->header .= "From: ". Mb_encode_mimeheader( $from_name )."<".$fromaddress.">\n"; |
---|
74 | $this->header .= "Reply-To: ". $reply_to . "\n"; |
---|
75 | $this->header .= "Cc: " . $cc. "\n"; |
---|
76 | $this->header .= "Bcc: " . $bcc . "\n"; |
---|
77 | $this->header .= "Errors-To: ". $errors_to ."\n"; |
---|
78 | $this->return_path = $return_path; |
---|
79 | } |
---|
80 | |
---|
81 | // メール送信を実行する |
---|
82 | function sendMail() { |
---|
83 | |
---|
84 | Mb_language( "Japanese" ); |
---|
85 | |
---|
86 | // メール送信 |
---|
87 | if( mb_send_mail( $this->to, $this->subject, $this->body, $this->header) ) { |
---|
88 | return true; |
---|
89 | } |
---|
90 | return false; |
---|
91 | } |
---|
92 | |
---|
93 | function sendHtmlMail() { |
---|
94 | |
---|
95 | Mb_language( "Japanese" ); |
---|
96 | |
---|
97 | // メール送信 |
---|
98 | if( mail( $this->to, $this->subject, $this->body, $this->header) ) { |
---|
99 | return true; |
---|
100 | } |
---|
101 | return false; |
---|
102 | } |
---|
103 | } |
---|
104 | |
---|
105 | ?> |
---|