回答編集履歴

4

追記回答文の\$fromに設定している最後の"\\r\\n"を削除

2016/11/30 06:45

投稿

Y.H.
Y.H.

スコア7914

test CHANGED
@@ -92,7 +92,7 @@
92
92
 
93
93
  // ・・・略・・・
94
94
 
95
- $from = "From:xxxxxxxxxxxxx\r\n";
95
+ $from = "From:xxxxxxxxxxxxx";
96
96
 
97
97
  // ・・・略・・・
98
98
 

3

回答内容追記

2016/11/30 06:45

投稿

Y.H.
Y.H.

スコア7914

test CHANGED
@@ -42,4 +42,60 @@
42
42
 
43
43
 
44
44
 
45
+ ###$fromもおかしい
45
46
 
47
+ tacsheavenさんの回答にある部分に加えて```$from```もなんだかおかしいですね。```Return-Path: ```ヘッダーをなぜ$fromに入れているのでしょう? ```$additional_headers```に入れるべきですね。
48
+
49
+
50
+
51
+ ```PHP
52
+
53
+ // ・・・略・・・
54
+
55
+ $additional_headers = "Content-Type: multipart/mixed;boundary=\"" . $boundary . "\"\n";
56
+
57
+ $additional_headers .= "From: xxxxxxx";
58
+
59
+ // ・・・略・・・
60
+
61
+ $from = "From:xxxxxxxxxxxxx\r\n";
62
+
63
+ $from .= "Return-Path: xxxxxxxx";
64
+
65
+ ```
66
+
67
+
68
+
69
+ こんな↓感じに修正
70
+
71
+
72
+
73
+ ```PHP
74
+
75
+ // ・・・略・・・
76
+
77
+ $additional_headers = implode("\r\n" ,
78
+
79
+ array(
80
+
81
+ 'Content-Type: multipart/mixed;boundary="' . $boundary . '"',
82
+
83
+ 'From: xxxxxxx',
84
+
85
+ 'Return-Path: xxxxxxxx',
86
+
87
+ )
88
+
89
+ );
90
+
91
+
92
+
93
+ // ・・・略・・・
94
+
95
+ $from = "From:xxxxxxxxxxxxx\r\n";
96
+
97
+ // ・・・略・・・
98
+
99
+ ```
100
+
101
+

2

追記:SMTPの改行コード

2016/11/30 06:37

投稿

Y.H.
Y.H.

スコア7914

test CHANGED
@@ -34,4 +34,12 @@
34
34
 
35
35
 
36
36
 
37
+ ###最後にご質問の件について、コード上で気になったこと
37
38
 
39
+ メール送信時の改行コードに```\n```を使用されていますが、OSのシステム改行コード(CR or CR+LF)にかかわらず SMTPプロトコルでは、メールヘッダー・メールボディーともに CR+LF ( ```\r\n``` )です。
40
+
41
+ ある程度MTAやMUAが柔軟に処理してくれる場合もありますが、CR+LF ( ```\r\n``` )を使用することをお勧めします。
42
+
43
+
44
+
45
+

1

Internal Server Errorの参考情報追記

2016/11/30 05:37

投稿

Y.H.
Y.H.

スコア7914

test CHANGED
@@ -19,3 +19,19 @@
19
19
  ini_set( 'error_reporting', E_ALL );
20
20
 
21
21
  ```
22
+
23
+
24
+
25
+ ---
26
+
27
+
28
+
29
+ **なんでみんなログもエラーメッセージも確認せず自分のコードにそこまで自信をもって開発できるんだろう?**
30
+
31
+ 参考:
32
+
33
+ [(teratail.com)HTTP ERROR 500 の解決方法](https://teratail.com/questions/56574)
34
+
35
+
36
+
37
+