質問編集履歴
2
ソース追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -43,3 +43,339 @@
|
|
43
43
|
会社のメーラー(Becky!)では上記のようにヘッダー情報などが本文に出てしまいます。
|
44
44
|
|
45
45
|
何が問題だと考えられますか?
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
ソースを追加すると
|
50
|
+
|
51
|
+
```becky!未対応
|
52
|
+
|
53
|
+
public function adminSend() {
|
54
|
+
|
55
|
+
// 送信先の設定
|
56
|
+
|
57
|
+
foreach ($this->adminArray as $value) {
|
58
|
+
|
59
|
+
$this->sendMail[] = mb_encode_mimeheader($this->adminName, "ISO-2022-JP-MS","UTF-8") ." <" . trim($value) . ">";
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
// タイトルの設定
|
66
|
+
|
67
|
+
$this->sendTitle = "{$this->requiredItem["name"]}様よりお問い合わせ";
|
68
|
+
|
69
|
+
$this->sendTitle = mb_encode_mimeheader($this->sendTitle, "ISO-2022-JP-MS","UTF-8");
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
// メッセージの設定
|
74
|
+
|
75
|
+
$this->sendMessage = "{$this->requiredItem["name"]}様より、下記内容でお問い合わせが届いています。\n";
|
76
|
+
|
77
|
+
$this->sendMessage .= "\n";
|
78
|
+
|
79
|
+
foreach ($this->submitContent as $key => $value) {
|
80
|
+
|
81
|
+
$this->sendMessage .= "■{$key}\n";
|
82
|
+
|
83
|
+
$this->sendMessage .= "{$value}\n\n";
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
$this->sendMessage .= "\n\n";
|
88
|
+
|
89
|
+
$this->sendMessage .= "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
|
90
|
+
|
91
|
+
$this->sendMessage .= "[送信日時]".date("Y年m月d日(D) H時i分s秒")."\n";
|
92
|
+
|
93
|
+
$this->sendMessage .= "[IPアドレス]{$this->server["REMOTE_ADDR"]}\n";
|
94
|
+
|
95
|
+
$this->sendMessage .= "[ホスト]{$this->server["REMOTE_HOST"]}\n";
|
96
|
+
|
97
|
+
$this->sendMessage .= "[USER_AGENT]{$this->server["HTTP_USER_AGENT"]}\n";
|
98
|
+
|
99
|
+
$this->sendMessage .= "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
|
100
|
+
|
101
|
+
$this->sendMessage = mb_convert_encoding($this->sendMessage, "ISO-2022-JP-MS","UTF-8");
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
//ヘッダーの設定
|
106
|
+
|
107
|
+
$this->sendHeaders = "X-Mailer: PHP5\r\n";
|
108
|
+
|
109
|
+
$this->sendHeaders = "MIME-Version: 1.0\r\n";
|
110
|
+
|
111
|
+
$this->sendHeaders .= "From: ".mb_encode_mimeheader($this->requiredItem["name"], "ISO-2022-JP-MS","UTF-8") ." <{$this->requiredItem["mailaddress"]}> \r\n";
|
112
|
+
|
113
|
+
$this->sendHeaders .= "Content-Transfer-Encoding: 7bit\r\n";
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
// 添付ファイルの設定
|
118
|
+
|
119
|
+
if (!empty($this->submitFile)) {
|
120
|
+
|
121
|
+
$this->sendHeaders .= "Content-type: multipart/mixed; boundary=\"{$this->boundary}\" \r\n";
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
$tmpMessage = $this->sendMessage;
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
$this->sendMessage = "--{$this->boundary}\n";
|
130
|
+
|
131
|
+
$this->sendMessage .= "Content-Type: text/plain; charset=\"ISO-2022-JP\"\n";
|
132
|
+
|
133
|
+
$this->sendMessage .= "Content-Transfer-Encoding: 7bit\n\n";
|
134
|
+
|
135
|
+
$this->sendMessage .= $tmpMessage."\n";
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
foreach ($this->submitFile as $key => $value) {
|
140
|
+
|
141
|
+
foreach ($value as $key2 => $value2) {
|
142
|
+
|
143
|
+
$name = $key2;
|
144
|
+
|
145
|
+
$f_encoded = $value2;
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
$this->sendMessage .= "\n";
|
150
|
+
|
151
|
+
$this->sendMessage .= "--{$this->boundary}\n";
|
152
|
+
|
153
|
+
$this->sendMessage .= "Content-Type: application/octet-stream; ";
|
154
|
+
|
155
|
+
$this->sendMessage .= "charset=\"ISO-2022-JP\" ";
|
156
|
+
|
157
|
+
$this->sendMessage .= "name=\"".mb_encode_mimeheader($name, "ISO-2022-JP-MS","UTF-8")."\"\n";
|
158
|
+
|
159
|
+
$this->sendMessage .= "Content-Transfer-Encoding: base64\n";
|
160
|
+
|
161
|
+
$this->sendMessage .= "Content-Disposition: attachment; ";
|
162
|
+
|
163
|
+
$this->sendMessage .= "filename=\"".mb_encode_mimeheader($name, "ISO-2022-JP-MS","UTF-8")."\"\n";
|
164
|
+
|
165
|
+
$this->sendMessage .= "\n";
|
166
|
+
|
167
|
+
$this->sendMessage .= "{$f_encoded}\n";
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
$this->sendMessage .= "--{$this->boundary}--\n";
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
} else {
|
180
|
+
|
181
|
+
$this->sendHeaders .= "Content-type: text/plain; charset=\"ISO-2022-JP\" \r\n";
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
// メールの送信 (宛先, 件名, 本文, 送り主(From:が必須))
|
188
|
+
|
189
|
+
foreach ($this->sendMail as $send) {
|
190
|
+
|
191
|
+
@mail($send, $this->sendTitle, $this->sendMessage, $this->sendHeaders);
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
```
|
198
|
+
|
199
|
+
```becky!でもファイル1個は問題なく受信できたソース
|
200
|
+
|
201
|
+
function sendmail_jpn($to, $subject, $message, $from_email,$from_name, $filepath01, $filepath02)
|
202
|
+
|
203
|
+
{
|
204
|
+
|
205
|
+
$mime_type = "application/octet-stream";
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
// 添付ファイルのエンコード
|
210
|
+
|
211
|
+
$filename01 = basename($filepath01);
|
212
|
+
|
213
|
+
$filename02 = basename($filepath02);
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
// マルチパートなので、パートの区切り文字列を指定
|
220
|
+
|
221
|
+
$boundary = '----=_Boundary_' . uniqid(rand(1000,9999) . '_') . '_';
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
// 件名のエンコード
|
226
|
+
|
227
|
+
$subject = mb_convert_encoding($subject, 'ISO-2022-JP', 'auto');
|
228
|
+
|
229
|
+
$subject = mb_encode_mimeheader_ex($subject);
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
// 本文のエンコード
|
234
|
+
|
235
|
+
$message = mb_convert_encoding($message, 'ISO-2022-JP', 'auto');
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
// toをエンコード
|
240
|
+
|
241
|
+
// $to = mb_convert_encoding($mail['to']['name'], "auto", "auto");
|
242
|
+
|
243
|
+
$to = "=?ISO-2022-JP?B?" . base64_encode($to) . '?= <' . $to . '>';
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
// fromをエンコード
|
248
|
+
|
249
|
+
$from_name = mb_convert_encoding($from_name, 'ISO-2022-JP', 'auto');
|
250
|
+
|
251
|
+
$from = "=?ISO-2022-JP?B?" . base64_encode($from_name) . '?= <' . $from_email . '>';
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
// 添付ファイルのエンコード01
|
256
|
+
|
257
|
+
$filename01 = mb_convert_encoding($filename01, 'ISO-2022-JP', 'auto');
|
258
|
+
|
259
|
+
$filename01 = "=?ISO-2022-JP?B?" . base64_encode($filename01) . "?=";
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
// 添付ファイルのエンコード02
|
264
|
+
|
265
|
+
$filename02 = mb_convert_encoding($filename02, 'ISO-2022-JP', 'auto');
|
266
|
+
|
267
|
+
$filename02 = "=?ISO-2022-JP?B?" . base64_encode($filename02) . "?=";
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
// ヘッダーの指定
|
272
|
+
|
273
|
+
$head = "";
|
274
|
+
|
275
|
+
$head .= "From: {$from}\n";
|
276
|
+
|
277
|
+
$head .= "MIME-Version: 1.0\n";
|
278
|
+
|
279
|
+
$head .= "Content-Type: multipart/mixed; boundary=\"{$boundary}\"\n";
|
280
|
+
|
281
|
+
$head .= "Content-Transfer-Encoding: 7bit";
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
$body = "";
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
// 本文
|
290
|
+
|
291
|
+
$body .= "--{$boundary}\n";
|
292
|
+
|
293
|
+
$body .= "Content-Type: text/plain; charset=ISO-2022-JP;" .
|
294
|
+
|
295
|
+
"Content-Transfer-Encoding: 7bit\n";
|
296
|
+
|
297
|
+
$body .= "\n";
|
298
|
+
|
299
|
+
$body .= "{$message}\n";
|
300
|
+
|
301
|
+
$body .= "\n";
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
// 添付ファイルの処理01
|
306
|
+
|
307
|
+
$body .= "--{$boundary}\n";
|
308
|
+
|
309
|
+
$body .= "Content-Type: {$mime_type}; name=\"{$filename01}\"\n" .
|
310
|
+
|
311
|
+
"Content-Transfer-Encoding: base64\n" .
|
312
|
+
|
313
|
+
"Content-Disposition: attachment; filename=\"{$filename01}\"\n";
|
314
|
+
|
315
|
+
$body .= "\n";
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
$fp = fopen( $filepath01, "r" ) or die("Error on mailing. (attachment file cannot open)");
|
320
|
+
|
321
|
+
$contents01 = fread( $fp, filesize($filepath01) );
|
322
|
+
|
323
|
+
fclose( $fp );
|
324
|
+
|
325
|
+
$f_encoded01 = chunk_split(base64_encode($contents01)); //添付ファイルをbase64エンコードする
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
// 添付ファイルの処理02
|
330
|
+
|
331
|
+
$body .= "--{$boundary}\n";
|
332
|
+
|
333
|
+
$body .= "Content-Type: {$mime_type}; name=\"{$filename02}\"\n" .
|
334
|
+
|
335
|
+
"Content-Transfer-Encoding: base64\n" .
|
336
|
+
|
337
|
+
"Content-Disposition: attachment; filename=\"{$filename02}\"\n";
|
338
|
+
|
339
|
+
$body .= "\n";
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
$fp = fopen( $filepath02, "r" ) or die("Error on mailing. (attachment file cannot open)");
|
344
|
+
|
345
|
+
$contents02 = fread( $fp, filesize($filepath02) );
|
346
|
+
|
347
|
+
fclose( $fp );
|
348
|
+
|
349
|
+
$f_encoded02 = chunk_split(base64_encode($contents02)); //添付ファイルをbase64エンコードする
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
$body .= "{$f_encoded01}\n\r";
|
354
|
+
|
355
|
+
//var_dump($body);
|
356
|
+
|
357
|
+
$body .= "{$f_encoded02}\n";
|
358
|
+
|
359
|
+
$body .= "\n";
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
if (mail($to, $subject, $body, $head)) {
|
368
|
+
|
369
|
+
echo 'sendmail_jpn : OK.';
|
370
|
+
|
371
|
+
} else {
|
372
|
+
|
373
|
+
echo 'sendmail_jpn : FAILURE.';
|
374
|
+
|
375
|
+
}
|
376
|
+
|
377
|
+
}
|
378
|
+
|
379
|
+
```
|
380
|
+
|
381
|
+
コードが長くて見難いですが一応追加しておきます。二つのコードのエンコードの仕方が違うみたいですが
|
1
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
![イメージ説明](4d59752e901bd7b1ca063b5b2c1f58a4.jpeg)
|
2
|
+
|
1
3
|
```受信メール内容
|
2
4
|
|
3
5
|
From: =?ISO-2022-JP?B?GyRCJUYlOSVIGyhC?= <hoge@hoge.com>
|