teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

4

削除された内容の復元を行いました

2020/12/01 04:37

投稿

tomato879241
tomato879241

スコア133

title CHANGED
File without changes
body CHANGED
@@ -1,1 +1,188 @@
1
+ ### 前提・実現したいこと
2
+ 自分、あまりPHPには詳しくないですが、iPhoneから遠隔サーバを通してメールを送るためのSendmailのコードを書いています。メールには複数の添付書類をつけることになっているので、**multipart**のContent-Typeを指定しています。以下のコードがそのPHPのコードです。
3
+ ### 該当のソースコード
4
+ ```PHP
5
+ <?php
6
+ error_reporting(E_ALL);
7
+ ini_set('display_errors', 1);
8
+ mb_internal_encoding ("UTF-8");
9
+
10
+ if(isset($_FILES) && (bool) $_FILES) {
11
+ $files = array();
12
+ foreach($_FILES as $name=>$file) {
13
+ $file_name = $file['name'];
14
+ $temp_name = $file['tmp_name'];
15
+ $file_type = $file['type'];
16
+ $path_parts = pathinfo($file_name);
17
+ $ext = $path_parts['extension'];
18
+ array_push($files, $file);
19
+ }
20
+
1
- xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx
21
+ // email fields: to, from, subject, and so on
22
+ $to = $_POST['mail_recipient'];
23
+ $cc = $_POST['mail_copy'];
24
+ $bcc = $_POST['mail_bcc'];
25
+ $from = $_POST['mail_sender'];
26
+ $myReturn = $_POST['mail_return'];
27
+ $subject = $_POST['mail_subject'];
28
+ $message = $_POST['mail_message'];
29
+ $returnpath = "-f" . $myReturn;
30
+ $headers = "From: $from\r\n";
31
+ $headers .= "Cc: $cc\r\n";
32
+ $headers .= "Bcc: $bcc";
33
+
34
+ // boundary
35
+ $semi_rand = md5(time());
36
+ $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
37
+
38
+ // headers for attachment
39
+ $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
40
+
41
+ // multipart boundary
42
+ $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain;\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
43
+ $message .= "--{$mime_boundary}\n";
44
+
45
+ // preparing attachments
46
+ for($x=0; $x<count($files); $x++){
47
+ $file = fopen($files[$x]['tmp_name'], "rb");
48
+ $data = fread($file, filesize($files[$x]['tmp_name']));
49
+ fclose($file);
50
+ $data = chunk_split(base64_encode($data));
51
+ $name = $files[$x]['name'];
52
+ $message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$name\"\n" .
53
+ "Content-Disposition: attachment;\n" . " filename=\"$name\"\n" .
54
+ "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
55
+ $message .= "--{$mime_boundary}\n";
56
+ }
57
+
58
+ // send
59
+ $ok = mail($to, $subject, $message, $headers, $returnpath);
60
+ if ($ok) {
61
+ echo "<p>mail sent to $to!</p>";
62
+ } else {
63
+ echo "<p>mail could not be sent!</p>";
64
+ }
65
+ } else {
66
+ // email fields: to, from, subject, and so on
67
+ $to = $_POST['mail_recipient'];
68
+ $cc = $_POST['mail_copy'];
69
+ $bcc = $_POST['mail_bcc'];
70
+ $from = $_POST['mail_sender'];
71
+ $myReturn = $_POST['mail_return'];
72
+ $subject = $_POST['mail_subject'];
73
+ $message = $_POST['mail_message'];
74
+ $returnpath = "-f" . $myReturn;
75
+ $headers = "From: $from\r\n";
76
+ $headers .= "Cc: $cc\r\n";
77
+ $headers .= "Bcc: $bcc";
78
+
79
+ // send
80
+ $ok = mail($to, $subject, $message, $headers, $returnpath);
81
+ if ($ok) {
82
+ echo "<p>mail sent to $to!</p>";
83
+ } else {
84
+ echo "<p>mail could not be sent!</p>";
85
+ }
86
+ }
87
+ ?>
88
+ ```
89
+ それで上のコードではメッセージの本文はPlain Textなんですが、それをHTML形式のテキストを送りたいのですが、どうしたらいいでしょうか?[このURL](https://www.tutorialrepublic.com/php-tutorial/php-send-email.php)にある説明を見ると、
90
+ ```PHP
91
+ $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
92
+ ```
93
+ とContent-typeを「text/html」にしろ、とあります。ただ自分の上のコードではすでにContent-typeを「multipart/mixed」と指定しています。すると両方を指定することはできるのでしょうか?
94
+ よろしくお願いします。
95
+ ### 更新1
96
+ どうも自分が誤解していたようです。自分のPHPのコードで
97
+ ```php
98
+ $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain;\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
99
+ ```
100
+ とあるので、ここを「text/html」に変えればいいんでしょうね。ただ[このURL](https://sendgrid.kke.co.jp/blog/?p=8262)にあるサイトによるとPlain TextとHTML Textの両方を送る、とあります。
101
+ ### 更新2
102
+ その後以下のように「Content-Type」を「text/html」に変更してみました。でもメールの内容はPlain Textで送られます。何がいけないのでしょうか?
103
+ ```PHP
104
+ <?php
105
+ error_reporting(E_ALL);
106
+ ini_set('display_errors', 1);
107
+ mb_internal_encoding ("UTF-8");
108
+
109
+ if(isset($_FILES) && (bool) $_FILES) {
110
+ $files = array();
111
+ foreach($_FILES as $name=>$file) {
112
+ $file_name = $file['name'];
113
+ $temp_name = $file['tmp_name'];
114
+ $file_type = $file['type'];
115
+ $path_parts = pathinfo($file_name);
116
+ $ext = $path_parts['extension'];
117
+ array_push($files, $file);
118
+ }
119
+
120
+ // email fields: to, from, subject, and so on
121
+ $to = $_POST['mail_recipient'];
122
+ $cc = $_POST['mail_copy'];
123
+ $bcc = $_POST['mail_bcc'];
124
+ $from = $_POST['mail_sender'];
125
+ $myReturn = $_POST['mail_return'];
126
+ $subject = $_POST['mail_subject'];
127
+ $message = $_POST['mail_message'];
128
+ $htmlMessage = $_POST['mail_html'];
129
+ $returnpath = "-f" . $myReturn;
130
+ $headers = "From: $from\r\n";
131
+ $headers .= "Cc: $cc\r\n";
132
+ $headers .= "Bcc: $bcc";
133
+
134
+ // boundary
135
+ $semi_rand = md5(time());
136
+ $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
137
+
138
+ // headers for attachment
139
+ $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
140
+
141
+ // multipart boundary
142
+ $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html;\n" . "Content-Transfer-Encoding: 7bit\n\n" . $htmlMessage . "\n\n";
143
+ $message .= "--{$mime_boundary}\n";
144
+
145
+ // preparing attachments
146
+ for($x=0; $x<count($files); $x++){
147
+ $file = fopen($files[$x]['tmp_name'], "rb");
148
+ $data = fread($file, filesize($files[$x]['tmp_name']));
149
+ fclose($file);
150
+ $data = chunk_split(base64_encode($data));
151
+ $name = $files[$x]['name'];
152
+ $message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$name\"\n" .
153
+ "Content-Disposition: attachment;\n" . " filename=\"$name\"\n" .
154
+ "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
155
+ $message .= "--{$mime_boundary}\n";
156
+ }
157
+
158
+ // send
159
+ $ok = mail($to, $subject, $message, $headers, $returnpath);
160
+ if ($ok) {
161
+ echo "<p>mail sent to $to!</p>";
162
+ } else {
163
+ echo "<p>mail could not be sent!</p>";
164
+ }
165
+ } else {
166
+ // email fields: to, from, subject, and so on
167
+ $to = $_POST['mail_recipient'];
168
+ $cc = $_POST['mail_copy'];
169
+ $bcc = $_POST['mail_bcc'];
170
+ $from = $_POST['mail_sender'];
171
+ $myReturn = $_POST['mail_return'];
172
+ $subject = $_POST['mail_subject'];
173
+ $message = $_POST['mail_message'];
174
+ $returnpath = "-f" . $myReturn;
175
+ $headers = "From: $from\r\n";
176
+ $headers .= "Cc: $cc\r\n";
177
+ $headers .= "Bcc: $bcc";
178
+
179
+ // send
180
+ $ok = mail($to, $subject, $message, $headers, $returnpath);
181
+ if ($ok) {
182
+ echo "<p>mail sent to $to!</p>";
183
+ } else {
184
+ echo "<p>mail could not be sent!</p>";
185
+ }
186
+ }
187
+ ?>
188
+ ```

3

xxxxx

2020/12/01 04:37

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,198 +1,1 @@
1
- ### 前提・実現したいこと
2
-
3
- 自分、あまりPHPには詳しくないですが、iPhoneから遠隔サーバを通してメールを送るためのSendmailのコードを書いています。メールには複数の添付書類をつけることになっているので、**multipart**のContent-Typeを指定しています。以下のコードがそのPHPのコードです。
4
-
5
- ### 該当のソースコード
6
-
7
- ```PHP
8
- <?php
9
- error_reporting(E_ALL);
10
- ini_set('display_errors', 1);
11
- mb_internal_encoding ("UTF-8");
12
-
13
- if(isset($_FILES) && (bool) $_FILES) {
14
- $files = array();
15
- foreach($_FILES as $name=>$file) {
16
- $file_name = $file['name'];
17
- $temp_name = $file['tmp_name'];
18
- $file_type = $file['type'];
19
- $path_parts = pathinfo($file_name);
20
- $ext = $path_parts['extension'];
21
- array_push($files, $file);
22
- }
23
-
24
- // email fields: to, from, subject, and so on
1
+ xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx
25
- $to = $_POST['mail_recipient'];
26
- $cc = $_POST['mail_copy'];
27
- $bcc = $_POST['mail_bcc'];
28
- $from = $_POST['mail_sender'];
29
- $myReturn = $_POST['mail_return'];
30
- $subject = $_POST['mail_subject'];
31
- $message = $_POST['mail_message'];
32
- $returnpath = "-f" . $myReturn;
33
- $headers = "From: $from\r\n";
34
- $headers .= "Cc: $cc\r\n";
35
- $headers .= "Bcc: $bcc";
36
-
37
- // boundary
38
- $semi_rand = md5(time());
39
- $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
40
-
41
- // headers for attachment
42
- $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
43
-
44
- // multipart boundary
45
- $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain;\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
46
- $message .= "--{$mime_boundary}\n";
47
-
48
- // preparing attachments
49
- for($x=0; $x<count($files); $x++){
50
- $file = fopen($files[$x]['tmp_name'], "rb");
51
- $data = fread($file, filesize($files[$x]['tmp_name']));
52
- fclose($file);
53
- $data = chunk_split(base64_encode($data));
54
- $name = $files[$x]['name'];
55
- $message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$name\"\n" .
56
- "Content-Disposition: attachment;\n" . " filename=\"$name\"\n" .
57
- "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
58
- $message .= "--{$mime_boundary}\n";
59
- }
60
-
61
- // send
62
- $ok = mail($to, $subject, $message, $headers, $returnpath);
63
- if ($ok) {
64
- echo "<p>mail sent to $to!</p>";
65
- } else {
66
- echo "<p>mail could not be sent!</p>";
67
- }
68
- } else {
69
- // email fields: to, from, subject, and so on
70
- $to = $_POST['mail_recipient'];
71
- $cc = $_POST['mail_copy'];
72
- $bcc = $_POST['mail_bcc'];
73
- $from = $_POST['mail_sender'];
74
- $myReturn = $_POST['mail_return'];
75
- $subject = $_POST['mail_subject'];
76
- $message = $_POST['mail_message'];
77
- $returnpath = "-f" . $myReturn;
78
- $headers = "From: $from\r\n";
79
- $headers .= "Cc: $cc\r\n";
80
- $headers .= "Bcc: $bcc";
81
-
82
- // send
83
- $ok = mail($to, $subject, $message, $headers, $returnpath);
84
- if ($ok) {
85
- echo "<p>mail sent to $to!</p>";
86
- } else {
87
- echo "<p>mail could not be sent!</p>";
88
- }
89
- }
90
- ?>
91
- ```
92
-
93
- それで上のコードではメッセージの本文はPlain Textなんですが、それをHTML形式のテキストを送りたいのですが、どうしたらいいでしょうか?[このURL](https://www.tutorialrepublic.com/php-tutorial/php-send-email.php)にある説明を見ると、
94
-
95
- ```PHP
96
- $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
97
- ```
98
- とContent-typeを「text/html」にしろ、とあります。ただ自分の上のコードではすでにContent-typeを「multipart/mixed」と指定しています。すると両方を指定することはできるのでしょうか?
99
-
100
- よろしくお願いします。
101
-
102
- ### 更新1
103
- どうも自分が誤解していたようです。自分のPHPのコードで
104
-
105
- ```php
106
- $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain;\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
107
- ```
108
- とあるので、ここを「text/html」に変えればいいんでしょうね。ただ[このURL](https://sendgrid.kke.co.jp/blog/?p=8262)にあるサイトによるとPlain TextとHTML Textの両方を送る、とあります。
109
-
110
- ### 更新2
111
- その後以下のように「Content-Type」を「text/html」に変更してみました。でもメールの内容はPlain Textで送られます。何がいけないのでしょうか?
112
-
113
- ```PHP
114
- <?php
115
- error_reporting(E_ALL);
116
- ini_set('display_errors', 1);
117
- mb_internal_encoding ("UTF-8");
118
-
119
- if(isset($_FILES) && (bool) $_FILES) {
120
- $files = array();
121
- foreach($_FILES as $name=>$file) {
122
- $file_name = $file['name'];
123
- $temp_name = $file['tmp_name'];
124
- $file_type = $file['type'];
125
- $path_parts = pathinfo($file_name);
126
- $ext = $path_parts['extension'];
127
- array_push($files, $file);
128
- }
129
-
130
- // email fields: to, from, subject, and so on
131
- $to = $_POST['mail_recipient'];
132
- $cc = $_POST['mail_copy'];
133
- $bcc = $_POST['mail_bcc'];
134
- $from = $_POST['mail_sender'];
135
- $myReturn = $_POST['mail_return'];
136
- $subject = $_POST['mail_subject'];
137
- $message = $_POST['mail_message'];
138
- $htmlMessage = $_POST['mail_html'];
139
- $returnpath = "-f" . $myReturn;
140
- $headers = "From: $from\r\n";
141
- $headers .= "Cc: $cc\r\n";
142
- $headers .= "Bcc: $bcc";
143
-
144
- // boundary
145
- $semi_rand = md5(time());
146
- $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
147
-
148
- // headers for attachment
149
- $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
150
-
151
- // multipart boundary
152
- $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html;\n" . "Content-Transfer-Encoding: 7bit\n\n" . $htmlMessage . "\n\n";
153
- $message .= "--{$mime_boundary}\n";
154
-
155
- // preparing attachments
156
- for($x=0; $x<count($files); $x++){
157
- $file = fopen($files[$x]['tmp_name'], "rb");
158
- $data = fread($file, filesize($files[$x]['tmp_name']));
159
- fclose($file);
160
- $data = chunk_split(base64_encode($data));
161
- $name = $files[$x]['name'];
162
- $message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$name\"\n" .
163
- "Content-Disposition: attachment;\n" . " filename=\"$name\"\n" .
164
- "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
165
- $message .= "--{$mime_boundary}\n";
166
- }
167
-
168
- // send
169
- $ok = mail($to, $subject, $message, $headers, $returnpath);
170
- if ($ok) {
171
- echo "<p>mail sent to $to!</p>";
172
- } else {
173
- echo "<p>mail could not be sent!</p>";
174
- }
175
- } else {
176
- // email fields: to, from, subject, and so on
177
- $to = $_POST['mail_recipient'];
178
- $cc = $_POST['mail_copy'];
179
- $bcc = $_POST['mail_bcc'];
180
- $from = $_POST['mail_sender'];
181
- $myReturn = $_POST['mail_return'];
182
- $subject = $_POST['mail_subject'];
183
- $message = $_POST['mail_message'];
184
- $returnpath = "-f" . $myReturn;
185
- $headers = "From: $from\r\n";
186
- $headers .= "Cc: $cc\r\n";
187
- $headers .= "Bcc: $bcc";
188
-
189
- // send
190
- $ok = mail($to, $subject, $message, $headers, $returnpath);
191
- if ($ok) {
192
- echo "<p>mail sent to $to!</p>";
193
- } else {
194
- echo "<p>mail could not be sent!</p>";
195
- }
196
- }
197
- ?>
198
- ```

2

コードの変更

2020/11/29 13:52

投稿

tomato879241
tomato879241

スコア133

title CHANGED
File without changes
body CHANGED
@@ -99,10 +99,100 @@
99
99
 
100
100
  よろしくお願いします。
101
101
 
102
- ### 更新
102
+ ### 更新1
103
103
  どうも自分が誤解していたようです。自分のPHPのコードで
104
104
 
105
105
  ```php
106
106
  $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain;\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
107
107
  ```
108
- とあるので、ここを「text/html」に変えればいいんでしょうね。ただ[このURL](https://sendgrid.kke.co.jp/blog/?p=8262)にあるサイトによるとPlain TextとHTML Textの両方を送る、とあります。
108
+ とあるので、ここを「text/html」に変えればいいんでしょうね。ただ[このURL](https://sendgrid.kke.co.jp/blog/?p=8262)にあるサイトによるとPlain TextとHTML Textの両方を送る、とあります。
109
+
110
+ ### 更新2
111
+ その後以下のように「Content-Type」を「text/html」に変更してみました。でもメールの内容はPlain Textで送られます。何がいけないのでしょうか?
112
+
113
+ ```PHP
114
+ <?php
115
+ error_reporting(E_ALL);
116
+ ini_set('display_errors', 1);
117
+ mb_internal_encoding ("UTF-8");
118
+
119
+ if(isset($_FILES) && (bool) $_FILES) {
120
+ $files = array();
121
+ foreach($_FILES as $name=>$file) {
122
+ $file_name = $file['name'];
123
+ $temp_name = $file['tmp_name'];
124
+ $file_type = $file['type'];
125
+ $path_parts = pathinfo($file_name);
126
+ $ext = $path_parts['extension'];
127
+ array_push($files, $file);
128
+ }
129
+
130
+ // email fields: to, from, subject, and so on
131
+ $to = $_POST['mail_recipient'];
132
+ $cc = $_POST['mail_copy'];
133
+ $bcc = $_POST['mail_bcc'];
134
+ $from = $_POST['mail_sender'];
135
+ $myReturn = $_POST['mail_return'];
136
+ $subject = $_POST['mail_subject'];
137
+ $message = $_POST['mail_message'];
138
+ $htmlMessage = $_POST['mail_html'];
139
+ $returnpath = "-f" . $myReturn;
140
+ $headers = "From: $from\r\n";
141
+ $headers .= "Cc: $cc\r\n";
142
+ $headers .= "Bcc: $bcc";
143
+
144
+ // boundary
145
+ $semi_rand = md5(time());
146
+ $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
147
+
148
+ // headers for attachment
149
+ $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
150
+
151
+ // multipart boundary
152
+ $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html;\n" . "Content-Transfer-Encoding: 7bit\n\n" . $htmlMessage . "\n\n";
153
+ $message .= "--{$mime_boundary}\n";
154
+
155
+ // preparing attachments
156
+ for($x=0; $x<count($files); $x++){
157
+ $file = fopen($files[$x]['tmp_name'], "rb");
158
+ $data = fread($file, filesize($files[$x]['tmp_name']));
159
+ fclose($file);
160
+ $data = chunk_split(base64_encode($data));
161
+ $name = $files[$x]['name'];
162
+ $message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$name\"\n" .
163
+ "Content-Disposition: attachment;\n" . " filename=\"$name\"\n" .
164
+ "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
165
+ $message .= "--{$mime_boundary}\n";
166
+ }
167
+
168
+ // send
169
+ $ok = mail($to, $subject, $message, $headers, $returnpath);
170
+ if ($ok) {
171
+ echo "<p>mail sent to $to!</p>";
172
+ } else {
173
+ echo "<p>mail could not be sent!</p>";
174
+ }
175
+ } else {
176
+ // email fields: to, from, subject, and so on
177
+ $to = $_POST['mail_recipient'];
178
+ $cc = $_POST['mail_copy'];
179
+ $bcc = $_POST['mail_bcc'];
180
+ $from = $_POST['mail_sender'];
181
+ $myReturn = $_POST['mail_return'];
182
+ $subject = $_POST['mail_subject'];
183
+ $message = $_POST['mail_message'];
184
+ $returnpath = "-f" . $myReturn;
185
+ $headers = "From: $from\r\n";
186
+ $headers .= "Cc: $cc\r\n";
187
+ $headers .= "Bcc: $bcc";
188
+
189
+ // send
190
+ $ok = mail($to, $subject, $message, $headers, $returnpath);
191
+ if ($ok) {
192
+ echo "<p>mail sent to $to!</p>";
193
+ } else {
194
+ echo "<p>mail could not be sent!</p>";
195
+ }
196
+ }
197
+ ?>
198
+ ```

1

その後調べてわかったこと

2020/11/28 13:26

投稿

tomato879241
tomato879241

スコア133

title CHANGED
File without changes
body CHANGED
@@ -97,4 +97,12 @@
97
97
  ```
98
98
  とContent-typeを「text/html」にしろ、とあります。ただ自分の上のコードではすでにContent-typeを「multipart/mixed」と指定しています。すると両方を指定することはできるのでしょうか?
99
99
 
100
- よろしくお願いします。
100
+ よろしくお願いします。
101
+
102
+ ### 更新
103
+ どうも自分が誤解していたようです。自分のPHPのコードで
104
+
105
+ ```php
106
+ $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain;\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
107
+ ```
108
+ とあるので、ここを「text/html」に変えればいいんでしょうね。ただ[このURL](https://sendgrid.kke.co.jp/blog/?p=8262)にあるサイトによるとPlain TextとHTML Textの両方を送る、とあります。