質問編集履歴

12

更新

2018/07/20 12:53

投稿

ryo-dev
ryo-dev

スコア437

test CHANGED
File without changes
test CHANGED
@@ -168,11 +168,17 @@
168
168
 
169
169
 
170
170
 
171
+ use PHPMailer\PHPMailer\PHPMailer;
172
+
173
+ use PHPMailer\PHPMailer\Exception;
174
+
175
+
176
+
171
177
  //require(dirname(__FILE__)."/../vendor/autoload.php");
172
178
 
173
- require(dirname(__FILE__)."/vendor/autoload.php");
179
+ //require(dirname(__FILE__)."/vendor/autoload.php");
180
+
174
-
181
+ require 'vendor/autoload.php';
175
-
176
182
 
177
183
  echo "メールを送信";
178
184
 

11

訂正

2018/07/20 12:53

投稿

ryo-dev
ryo-dev

スコア437

test CHANGED
File without changes
test CHANGED
File without changes

10

訂正

2018/07/20 12:22

投稿

ryo-dev
ryo-dev

スコア437

test CHANGED
File without changes
test CHANGED
@@ -204,9 +204,9 @@
204
204
 
205
205
  $mail->Host = 'send.com:25'; // SMTPサーバーアドレス:ポート番号
206
206
 
207
- $mail->Username = 'aniran.info@gmail.com'; // SMTP認証用のユーザーID
207
+ $mail->Username = '*******@gmail.com'; // SMTP認証用のユーザーID
208
-
208
+
209
- $mail->Password = 'ryou0810'; // SMTP認証用のパスワード
209
+ $mail->Password = 'pass'; // SMTP認証用のパスワード
210
210
 
211
211
 
212
212
 

9

訂正

2018/07/20 12:17

投稿

ryo-dev
ryo-dev

スコア437

test CHANGED
File without changes
test CHANGED
@@ -170,7 +170,7 @@
170
170
 
171
171
  //require(dirname(__FILE__)."/../vendor/autoload.php");
172
172
 
173
- require(dirname(__FILE__)."/autoload.php");
173
+ require(dirname(__FILE__)."/vendor/autoload.php");
174
174
 
175
175
 
176
176
 

8

追記

2018/07/20 12:12

投稿

ryo-dev
ryo-dev

スコア437

test CHANGED
File without changes
test CHANGED
@@ -87,3 +87,145 @@
87
87
 
88
88
 
89
89
  ```
90
+
91
+
92
+
93
+ 上の配置で、index.phpへ`require(dirname(__FILE__)."/../vendor/autoload.php");`と記述しautoload.phpを呼び出した結果以下のエラーが発生しました。
94
+
95
+ ```ここに言語を入力
96
+
97
+ Fatal error: Uncaught Error: Class 'PHPMailer' not found in /var/www/html/index.php:17 Stack trace: #0 {main} thrown in /var/www/html/index.php on line 17
98
+
99
+ ```
100
+
101
+ $mail = new PHPMailer();でPHPMailerクラスが見つからないと言われています。
102
+
103
+
104
+
105
+
106
+
107
+ Kosuke_Shibuyaさんから、index.phpとvendorを同じ場所に配置しないと行けないと回答を頂いたので、配置を以下のように変更しました。
108
+
109
+ ```text
110
+
111
+ var/
112
+
113
+ |-www/
114
+
115
+ |-html
116
+
117
+ |-index.php
118
+
119
+   |-vendor
120
+
121
+ |-autoload.php
122
+
123
+ |-composer
124
+
125
+ | |- ......
126
+
127
+ |-phpmailer
128
+
129
+ |- ......
130
+
131
+
132
+
133
+ ```
134
+
135
+ index.phpでの呼び出しも変更しました。
136
+
137
+ require(dirname(__FILE__)."/../vendor/autoload.php");
138
+
139
+
140
+
141
+ require(dirname(__FILE__)."/autoload.php");
142
+
143
+ ですが、エラー内容は変わらず、
144
+
145
+ ```ここに言語を入力
146
+
147
+ Fatal error: Uncaught Error: Class 'PHPMailer' not found in /var/www/html/index.php:17 Stack trace: #0 {main} thrown in /var/www/html/index.php on line 17
148
+
149
+ ```
150
+
151
+ と言われています。
152
+
153
+
154
+
155
+ 現在のソースは以下のようになってます。
156
+
157
+
158
+
159
+ ```php
160
+
161
+ <?php
162
+
163
+
164
+
165
+ ini_set('display_errors', true);
166
+
167
+ error_reporting(E_ALL);
168
+
169
+
170
+
171
+ //require(dirname(__FILE__)."/../vendor/autoload.php");
172
+
173
+ require(dirname(__FILE__)."/autoload.php");
174
+
175
+
176
+
177
+ echo "メールを送信";
178
+
179
+
180
+
181
+ $to = "*******@yahoo.co.jp"; //宛先
182
+
183
+ $subject = "メールの件名"; //件名
184
+
185
+ $body = "メールの本文です。"; //本文
186
+
187
+ $from = "*******@gmail.com"; //差出人
188
+
189
+ $fromname = "送信者"; //差し出し人名
190
+
191
+
192
+
193
+ $mail = new PHPMailer();
194
+
195
+ $mail->CharSet = "iso-2022-jp";
196
+
197
+ $mail->Encoding = "7bit";
198
+
199
+
200
+
201
+ $mail->IsSMTP(); //「SMTPサーバーを使うよ」設定
202
+
203
+ $mail->SMTPAuth = TRUE; //「SMTP認証を使うよ」設定
204
+
205
+ $mail->Host = 'send.com:25'; // SMTPサーバーアドレス:ポート番号
206
+
207
+ $mail->Username = 'aniran.info@gmail.com'; // SMTP認証用のユーザーID
208
+
209
+ $mail->Password = 'ryou0810'; // SMTP認証用のパスワード
210
+
211
+
212
+
213
+ $mail->AddAddress($to);
214
+
215
+ $mail->From = $from;
216
+
217
+ $mail->FromName = mb_encode_mimeheader(mb_convert_encoding($fromname,"JIS","UTF-8"));
218
+
219
+ $mail->Subject = mb_encode_mimeheader(mb_convert_encoding($subject,"JIS","UTF-8"));
220
+
221
+ $mail->Body = mb_convert_encoding($body,"JIS","UTF-8");
222
+
223
+
224
+
225
+ //メールを送信
226
+
227
+ $mail->Send();
228
+
229
+ ?>
230
+
231
+ ```

7

訂正

2018/07/20 10:33

投稿

ryo-dev
ryo-dev

スコア437

test CHANGED
File without changes
test CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
 
22
22
 
23
- require("../vendor/autoload.php");
23
+ require(dirname(__FILE__)."/../vendor/autoload.php");
24
24
 
25
25
 
26
26
 

6

訂正

2018/07/20 08:41

投稿

ryo-dev
ryo-dev

スコア437

test CHANGED
File without changes
test CHANGED
@@ -76,11 +76,13 @@
76
76
 
77
77
  | |-index.php
78
78
 
79
- |-autoload.php
79
+ |-vendor
80
80
 
81
- |-composer
81
+ |-autoload.php
82
82
 
83
+ |-composer
84
+
83
- |-phpmailer
85
+ |-phpmailer
84
86
 
85
87
 
86
88
 

5

追記

2018/07/20 08:39

投稿

ryo-dev
ryo-dev

スコア437

test CHANGED
File without changes
test CHANGED
@@ -61,3 +61,27 @@
61
61
  何処をどうすればよいのかが全くわかりません。
62
62
 
63
63
  指定すべきものを指定していなかったり、するところがあれば教えて下さい。
64
+
65
+
66
+
67
+ ### 追記
68
+
69
+ ```text
70
+
71
+ var/
72
+
73
+ |-www/
74
+
75
+ |-html
76
+
77
+ | |-index.php
78
+
79
+ |-autoload.php
80
+
81
+ |-composer
82
+
83
+ |-phpmailer
84
+
85
+
86
+
87
+ ```

4

訂正

2018/07/20 08:35

投稿

ryo-dev
ryo-dev

スコア437

test CHANGED
File without changes
test CHANGED
@@ -12,17 +12,19 @@
12
12
 
13
13
  <?php
14
14
 
15
+
16
+
15
- ini_set('display_errors', "1" );
17
+ ini_set('display_errors', true);
18
+
19
+ error_reporting(E_ALL);
16
20
 
17
21
 
18
22
 
19
- echo "メール送信";
23
+ require("../vendor/autoload.php");
20
24
 
21
25
 
22
26
 
23
- mb_language("Japanese");
27
+ echo "メールを送信";
24
-
25
- mb_internal_encoding("UTF-8");
26
28
 
27
29
 
28
30
 

3

訂正

2018/07/20 08:30

投稿

ryo-dev
ryo-dev

スコア437

test CHANGED
File without changes
test CHANGED
@@ -32,7 +32,7 @@
32
32
 
33
33
  $message = 'body';
34
34
 
35
- $headers = 'From:'*******@gmail.com' . "\r\n";
35
+ $headers = 'From:'.'*******@gmail.com' . "\r\n";
36
36
 
37
37
 
38
38
 

2

訂正

2018/07/19 11:11

投稿

ryo-dev
ryo-dev

スコア437

test CHANGED
File without changes
test CHANGED
@@ -26,13 +26,13 @@
26
26
 
27
27
 
28
28
 
29
- $to = '送信先アドレス';
29
+ $to = '*******@yahoo.co.jp';
30
30
 
31
31
  $subject = 'title';
32
32
 
33
33
  $message = 'body';
34
34
 
35
- $headers = 'From:送信元アドレス' . "\r\n";
35
+ $headers = 'From:'*******@gmail.com' . "\r\n";
36
36
 
37
37
 
38
38
 

1

訂正

2018/07/19 10:26

投稿

ryo-dev
ryo-dev

スコア437

test CHANGED
File without changes
test CHANGED
File without changes