質問編集履歴

2

github情報削除

2024/04/27 12:49

投稿

DaisukeMori
DaisukeMori

スコア229

test CHANGED
File without changes
test CHANGED
@@ -9,101 +9,3 @@
9
9
 
10
10
  ### 発生している問題・分からないこと
11
11
  MailHogのMINE内に添付ファイルが届かない。
12
-
13
-
14
-
15
- ### 該当のソースコード
16
-
17
- ```php
18
- <?php
19
- // メール送信のファイル
20
-
21
- // 変数一覧
22
- $header = null;
23
- $body = null;
24
- $reply_subject = null;
25
- $reply_text = null;
26
- $notice_subject = null;
27
- $notice_text = null;
28
-
29
- // メールヘッダー情報
30
- $header = "MIME-Version: 1.0\n";
31
- $header .= "Content-Type: multipart/mixed;boundary=\"__BOUNDARY__\"\n";
32
- // $header .= "Content-Type: text/plain;charset=UTF-8\n";
33
- $header .= "From: <example@example.com>\n";
34
- $header .= "Reply-To: <example@example.com>\n";
35
-
36
- // 自動返信メール件名
37
- $reply_subject = "お問い合わせいただきありがとうございます";
38
-
39
- // 自動返信メール本文
40
- $reply_text = "下記の内容でお問い合わせを受け付けました。"."\n\n";
41
- $reply_text .= "お問い合わせ受付日時:".date('Y-m-d H:i')."\n";
42
- $reply_text .= "選択ボックス:".$esc['box']."\n";
43
- $reply_text .= "お名前:".$esc['fullname']."\n";
44
- $reply_text .= "メールアドレス:".$esc['email']."\n";
45
- $reply_text .= "電話番号:".$esc['tel']."\n";
46
- $reply_text .= "お問い合わせ内容:".$esc['message']."\n\n";
47
- $reply_text .= "送信元: ホームページ管理者<example@example.com>";
48
-
49
- // 自動返信メールの送信
50
- mail($esc['email'], $reply_subject, $reply_text, $header);
51
-
52
- // 管理者通知メールの件名
53
- $notice_subject = "ホームページからメッセージがありました";
54
-
55
- // 管理者通知メールの本文
56
- $notice_text = "下記の内容でお問い合わせを受け付けました。"."\n\n";
57
- $notice_text .= "お問い合わせ受付日時:".date('Y-m-d H:i')."\n";
58
- $notice_text .= "選択ボックス:".$esc['box']."\n";
59
- $notice_text .= "お名前:".$esc['fullname']."\n";
60
- $notice_text .= "メールアドレス:".$esc['email']."\n";
61
- $notice_text .= "電話番号:".$esc['tel']."\n";
62
- $notice_text .= "お問い合わせ内容:".$esc['message']."\n";
63
- $notice_text .= "プライバシーポリシー:".$esc['agree']."\n";
64
-
65
- // テキストメッセージをセット
66
- $body = "--__BOUNDARY__\n";
67
- $body .= "Content-Type: text/plain; charset=\"ISO-2022-JP\"\n\n";
68
- $body .= $notice_text . "\n";
69
- $body .= "--__BOUNDARY__\n";
70
-
71
- // ファイルを添付
72
- if( !empty($esc['attachment_file']) ) {
73
- $body .= "Content-Type: application/octet-stream; name=\"{$esc['attachment_file']}\"\n";
74
- $body .= "Content-Disposition: attachment; filename=\"{$esc['attachment_file']}\"\n";
75
- $body .= "Content-Transfer-Encoding: base64\n";
76
- $body .= "\n";
77
- $body .= chunk_split(base64_encode(file_get_contents(FILE_DIR.$esc['attachment_file'])));
78
- $body .= "--__BOUNDARY__\n";
79
- }
80
-
81
- // 管理者通知メールの送信
82
- mail('example@example.com', $notice_subject, $body, $header);
83
- ```
84
-
85
- ### 試したこと・調べたこと
86
- - [x] teratailやGoogle等で検索した
87
- - [x] ソースコードを自分なりに変更した
88
- - [ ] 知人に聞いた
89
- - [ ] その他
90
-
91
- ##### 上記の詳細・結果
92
- 参考にした記事はこちら
93
- [https://gray-code.com/php/make-the-form-vol9/](https://gray-code.com/php/make-the-form-vol9/)
94
-
95
- まず初めにMailHogで本当に添付ファイルが送れたことを確認するために
96
- ContactForm7でテストし、無事に届くことは確認。
97
-
98
- ### 補足
99
- 環境
100
- - WordPressローカル構築のLocal - MailHog
101
-
102
- コード全文
103
- [GitHub](https://github.com/d-mori-src/wp-dev)
104
-
105
- 環境構築
106
- - LocalにてWordPress構築
107
- - このテーマファイルを入れる
108
- - 固定ページにcontact追加(パーマリンクボタンを必ず押す)
109
- - public直下に「/strage/mail/」フォルダを入れる(この場所に添付ファイルが入るようにしています)

1

1箇所記述抜け

2024/04/18 05:25

投稿

DaisukeMori
DaisukeMori

スコア229

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  - テキストベースの送信 済
6
6
  - 確認画面 済
7
- - 添付ファイルをフォルダ内にアップロード
7
+ - 添付ファイルをフォルダ内にアップロード 済
8
8
  - 添付ファイルの送信 未
9
9
 
10
10
  ### 発生している問題・分からないこと