|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of EC-CUBE |
|
4
|
|
|
* |
|
5
|
|
|
* Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. |
|
6
|
|
|
* |
|
7
|
|
|
* http://www.lockon.co.jp/ |
|
8
|
|
|
* |
|
9
|
|
|
* This program is free software; you can redistribute it and/or |
|
10
|
|
|
* modify it under the terms of the GNU General Public License |
|
11
|
|
|
* as published by the Free Software Foundation; either version 2 |
|
12
|
|
|
* of the License, or (at your option) any later version. |
|
13
|
|
|
* |
|
14
|
|
|
* This program is distributed in the hope that it will be useful, |
|
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17
|
|
|
* GNU General Public License for more details. |
|
18
|
|
|
* |
|
19
|
|
|
* You should have received a copy of the GNU General Public License |
|
20
|
|
|
* along with this program; if not, write to the Free Software |
|
21
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
namespace Eccube\Service; |
|
25
|
|
|
|
|
26
|
|
|
use Eccube\Application; |
|
27
|
|
|
use Eccube\Event\EccubeEvents; |
|
28
|
|
|
use Eccube\Event\EventArgs; |
|
29
|
|
|
|
|
30
|
|
|
class MailService |
|
|
|
|
|
|
31
|
|
|
{ |
|
32
|
|
|
/** @var \Eccube\Application */ |
|
33
|
|
|
public $app; |
|
34
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
/** @var \Eccube\Entity\BaseInfo */ |
|
37
|
|
|
public $BaseInfo; |
|
|
|
|
|
|
38
|
|
|
|
|
39
|
24 |
|
public function __construct(Application $app) |
|
|
|
|
|
|
40
|
|
|
{ |
|
41
|
24 |
|
$this->app = $app; |
|
42
|
|
|
$this->BaseInfo = $app['eccube.repository.base_info']->get(); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
/** |
|
|
|
|
|
|
47
|
|
|
* Send customer confirm mail. |
|
48
|
|
|
* |
|
49
|
|
|
* @param $Customer 会員情報 |
|
|
|
|
|
|
50
|
|
|
* @param $activateUrl アクティベート用url |
|
|
|
|
|
|
51
|
|
|
*/ |
|
52
|
2 |
|
public function sendCustomerConfirmMail(\Eccube\Entity\Customer $Customer, $activateUrl) |
|
53
|
|
|
{ |
|
54
|
|
|
|
|
55
|
|
|
$body = $this->app->renderView('Mail/entry_confirm.twig', array( |
|
56
|
|
|
'Customer' => $Customer, |
|
57
|
2 |
|
'BaseInfo' => $this->BaseInfo, |
|
58
|
|
|
'activateUrl' => $activateUrl, |
|
59
|
|
|
)); |
|
60
|
|
|
|
|
61
|
2 |
|
$message = \Swift_Message::newInstance() |
|
62
|
|
|
->setSubject('[' . $this->BaseInfo->getShopName() . '] 会員登録のご確認') |
|
|
|
|
|
|
63
|
|
|
->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName())) |
|
64
|
|
|
->setTo(array($Customer->getEmail())) |
|
65
|
|
|
->setBcc($this->BaseInfo->getEmail01()) |
|
66
|
|
|
->setReplyTo($this->BaseInfo->getEmail03()) |
|
67
|
|
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
68
|
|
|
->setBody($body); |
|
69
|
|
|
|
|
70
|
|
|
$event = new EventArgs( |
|
71
|
|
|
array( |
|
72
|
|
|
'message' => $message, |
|
73
|
|
|
'Customer' => $Customer, |
|
74
|
2 |
|
'BaseInfo' => $this->BaseInfo, |
|
75
|
|
|
'activateUrl' => $activateUrl, |
|
76
|
|
|
), |
|
77
|
2 |
|
$this->app['request'] |
|
78
|
|
|
); |
|
79
|
|
|
$this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_CUSTOMER_CONFIRM, $event); |
|
80
|
|
|
|
|
81
|
|
|
$this->app->mail($message); |
|
82
|
1 |
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
|
|
|
|
|
85
|
|
|
* Send customer complete mail. |
|
86
|
|
|
* |
|
87
|
|
|
* @param $Customer 会員情報 |
|
|
|
|
|
|
88
|
|
|
*/ |
|
89
|
2 |
View Code Duplication |
public function sendCustomerCompleteMail(\Eccube\Entity\Customer $Customer) |
|
|
|
|
|
|
90
|
|
|
{ |
|
91
|
|
|
|
|
92
|
|
|
$body = $this->app->renderView('Mail/entry_complete.twig', array( |
|
93
|
|
|
'Customer' => $Customer, |
|
94
|
2 |
|
'BaseInfo' => $this->BaseInfo, |
|
95
|
|
|
)); |
|
96
|
|
|
|
|
97
|
2 |
|
$message = \Swift_Message::newInstance() |
|
98
|
|
|
->setSubject('[' . $this->BaseInfo->getShopName() . '] 会員登録が完了しました。') |
|
|
|
|
|
|
99
|
|
|
->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName())) |
|
100
|
|
|
->setTo(array($Customer->getEmail())) |
|
101
|
|
|
->setBcc($this->BaseInfo->getEmail01()) |
|
102
|
|
|
->setReplyTo($this->BaseInfo->getEmail03()) |
|
103
|
|
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
104
|
|
|
->setBody($body); |
|
105
|
|
|
|
|
106
|
|
|
$event = new EventArgs( |
|
107
|
|
|
array( |
|
108
|
|
|
'message' => $message, |
|
109
|
|
|
'Customer' => $Customer, |
|
110
|
2 |
|
'BaseInfo' => $this->BaseInfo, |
|
111
|
|
|
), |
|
112
|
2 |
|
$this->app['request'] |
|
113
|
|
|
); |
|
114
|
|
|
$this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_CUSTOMER_COMPLETE, $event); |
|
115
|
|
|
|
|
116
|
|
|
$this->app->mail($message); |
|
117
|
|
|
|
|
118
|
1 |
|
} |
|
119
|
|
|
|
|
120
|
|
|
|
|
121
|
|
|
/** |
|
|
|
|
|
|
122
|
|
|
* Send withdraw mail. |
|
123
|
|
|
* |
|
124
|
|
|
* @param $Customer 会員情報 |
|
|
|
|
|
|
125
|
|
|
* @param $email 会員email |
|
|
|
|
|
|
126
|
|
|
*/ |
|
127
|
2 |
View Code Duplication |
public function sendCustomerWithdrawMail(\Eccube\Entity\Customer $Customer, $email) |
|
|
|
|
|
|
128
|
|
|
{ |
|
129
|
|
|
|
|
130
|
|
|
$body = $this->app->renderView('Mail/customer_withdraw_mail.twig', array( |
|
131
|
|
|
'Customer' => $Customer, |
|
132
|
2 |
|
'BaseInfo' => $this->BaseInfo, |
|
133
|
|
|
)); |
|
134
|
|
|
|
|
135
|
2 |
|
$message = \Swift_Message::newInstance() |
|
136
|
|
|
->setSubject('[' . $this->BaseInfo->getShopName() . '] 退会手続きのご完了') |
|
|
|
|
|
|
137
|
|
|
->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName())) |
|
138
|
2 |
|
->setTo(array($email)) |
|
139
|
|
|
->setBcc($this->BaseInfo->getEmail01()) |
|
140
|
|
|
->setReplyTo($this->BaseInfo->getEmail03()) |
|
141
|
|
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
142
|
|
|
->setBody($body); |
|
143
|
|
|
|
|
144
|
|
|
$event = new EventArgs( |
|
145
|
|
|
array( |
|
146
|
|
|
'message' => $message, |
|
147
|
|
|
'Customer' => $Customer, |
|
148
|
2 |
|
'BaseInfo' => $this->BaseInfo, |
|
149
|
|
|
'email' => $email, |
|
150
|
|
|
), |
|
151
|
2 |
|
$this->app['request'] |
|
152
|
|
|
); |
|
153
|
|
|
$this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_CUSTOMER_WITHDRAW, $event); |
|
154
|
|
|
|
|
155
|
|
|
$this->app->mail($message); |
|
156
|
|
|
|
|
157
|
1 |
|
} |
|
158
|
|
|
|
|
159
|
|
|
|
|
160
|
|
|
/** |
|
|
|
|
|
|
161
|
|
|
* Send contact mail. |
|
162
|
|
|
* |
|
163
|
|
|
* @param $formData お問い合わせ内容 |
|
|
|
|
|
|
164
|
|
|
*/ |
|
165
|
5 |
View Code Duplication |
public function sendContactMail($formData) |
|
|
|
|
|
|
166
|
|
|
{ |
|
167
|
|
|
|
|
168
|
|
|
$body = $this->app->renderView('Mail/contact_mail.twig', array( |
|
169
|
|
|
'data' => $formData, |
|
170
|
5 |
|
'BaseInfo' => $this->BaseInfo, |
|
171
|
|
|
)); |
|
172
|
|
|
|
|
173
|
|
|
// 問い合わせ者にメール送信 |
|
174
|
5 |
|
$message = \Swift_Message::newInstance() |
|
175
|
|
|
->setSubject('[' . $this->BaseInfo->getShopName() . '] お問い合わせを受け付けました。') |
|
|
|
|
|
|
176
|
|
|
->setFrom(array($this->BaseInfo->getEmail02() => $this->BaseInfo->getShopName())) |
|
177
|
5 |
|
->setTo(array($formData['email'])) |
|
178
|
|
|
->setBcc($this->BaseInfo->getEmail02()) |
|
179
|
|
|
->setReplyTo($this->BaseInfo->getEmail02()) |
|
180
|
|
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
181
|
|
|
->setBody($body); |
|
182
|
|
|
|
|
183
|
|
|
$event = new EventArgs( |
|
184
|
|
|
array( |
|
185
|
|
|
'message' => $message, |
|
186
|
|
|
'data' => $formData, |
|
187
|
5 |
|
'BaseInfo' => $this->BaseInfo, |
|
188
|
|
|
), |
|
189
|
5 |
|
$this->app['request'] |
|
190
|
|
|
); |
|
191
|
|
|
$this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_CONTACT, $event); |
|
192
|
|
|
|
|
193
|
|
|
$this->app->mail($message); |
|
194
|
|
|
|
|
195
|
3 |
|
} |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
|
|
|
|
|
198
|
|
|
* Alias of sendContactMail(). |
|
199
|
|
|
* |
|
200
|
|
|
* @param $formData お問い合わせ内容 |
|
|
|
|
|
|
201
|
|
|
* @see sendContactMail() |
|
202
|
|
|
* @deprecated since 3.0.0, to be removed in 3.1 |
|
203
|
|
|
* @link https://github.com/EC-CUBE/ec-cube/issues/1315 |
|
204
|
|
|
*/ |
|
205
|
1 |
|
public function sendrContactMail($formData) |
|
206
|
|
|
{ |
|
207
|
1 |
|
$this->sendContactMail($formData); |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
|
|
|
|
|
211
|
|
|
* Send order mail. |
|
212
|
|
|
* |
|
213
|
|
|
* @param $Order 受注情報 |
|
|
|
|
|
|
214
|
|
|
*/ |
|
215
|
5 |
|
public function sendOrderMail(\Eccube\Entity\Order $Order) |
|
216
|
|
|
{ |
|
217
|
|
|
|
|
218
|
|
|
$MailTemplate = $this->app['eccube.repository.mail_template']->find(1); |
|
219
|
|
|
|
|
220
|
|
|
$body = $this->app->renderView($MailTemplate->getFileName(), array( |
|
221
|
5 |
|
'header' => $MailTemplate->getHeader(), |
|
222
|
5 |
|
'footer' => $MailTemplate->getFooter(), |
|
223
|
|
|
'Order' => $Order, |
|
224
|
|
|
)); |
|
225
|
|
|
|
|
226
|
5 |
|
$message = \Swift_Message::newInstance() |
|
227
|
|
|
->setSubject('[' . $this->BaseInfo->getShopName() . '] ' . $MailTemplate->getSubject()) |
|
|
|
|
|
|
228
|
|
|
->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName())) |
|
229
|
|
|
->setTo(array($Order->getEmail())) |
|
230
|
|
|
->setBcc($this->BaseInfo->getEmail01()) |
|
231
|
|
|
->setReplyTo($this->BaseInfo->getEmail03()) |
|
232
|
|
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
233
|
|
|
->setBody($body); |
|
234
|
|
|
|
|
235
|
|
|
$event = new EventArgs( |
|
236
|
|
|
array( |
|
237
|
|
|
'message' => $message, |
|
238
|
|
|
'order' => $Order, |
|
239
|
|
|
'mailTemplate' => $MailTemplate, |
|
240
|
5 |
|
'BaseInfo' => $this->BaseInfo, |
|
241
|
|
|
), |
|
242
|
5 |
|
$this->app['request'] |
|
243
|
|
|
); |
|
244
|
|
|
$this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_ORDER, $event); |
|
245
|
|
|
|
|
246
|
|
|
$this->app->mail($message); |
|
247
|
|
|
|
|
248
|
1 |
|
} |
|
249
|
|
|
|
|
250
|
|
|
|
|
251
|
|
|
/** |
|
|
|
|
|
|
252
|
|
|
* Send admin customer confirm mail. |
|
253
|
|
|
* |
|
254
|
|
|
* @param $Customer 会員情報 |
|
|
|
|
|
|
255
|
|
|
* @param $activateUrl アクティベート用url |
|
|
|
|
|
|
256
|
|
|
*/ |
|
257
|
2 |
View Code Duplication |
public function sendAdminCustomerConfirmMail(\Eccube\Entity\Customer $Customer, $activateUrl) |
|
|
|
|
|
|
258
|
|
|
{ |
|
259
|
|
|
|
|
260
|
|
|
$body = $this->app->renderView('Mail/entry_confirm.twig', array( |
|
261
|
|
|
'Customer' => $Customer, |
|
262
|
|
|
'activateUrl' => $activateUrl, |
|
263
|
|
|
)); |
|
264
|
|
|
|
|
265
|
2 |
|
$message = \Swift_Message::newInstance() |
|
266
|
|
|
->setSubject('[' . $this->BaseInfo->getShopName() . '] 会員登録のご確認') |
|
|
|
|
|
|
267
|
|
|
->setFrom(array($this->BaseInfo->getEmail03() => $this->BaseInfo->getShopName())) |
|
268
|
|
|
->setTo(array($Customer->getEmail())) |
|
269
|
|
|
->setBcc($this->BaseInfo->getEmail01()) |
|
270
|
|
|
->setReplyTo($this->BaseInfo->getEmail03()) |
|
271
|
|
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
272
|
|
|
->setBody($body); |
|
273
|
|
|
|
|
274
|
|
|
$event = new EventArgs( |
|
275
|
|
|
array( |
|
276
|
|
|
'message' => $message, |
|
277
|
|
|
'Customer' => $Customer, |
|
278
|
2 |
|
'BaseInfo' => $this->BaseInfo, |
|
279
|
|
|
'activateUrl' => $activateUrl, |
|
280
|
|
|
), |
|
281
|
2 |
|
$this->app['request'] |
|
282
|
|
|
); |
|
283
|
|
|
$this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_ADMIN_CUSTOMER_CONFIRM, $event); |
|
284
|
|
|
|
|
285
|
|
|
$this->app->mail($message); |
|
286
|
|
|
|
|
287
|
1 |
|
} |
|
288
|
|
|
|
|
289
|
|
|
|
|
290
|
|
|
/** |
|
|
|
|
|
|
291
|
|
|
* Send admin order mail. |
|
292
|
|
|
* |
|
293
|
|
|
* @param $Order 受注情報 |
|
|
|
|
|
|
294
|
|
|
* @param $formData 入力内容 |
|
|
|
|
|
|
295
|
|
|
*/ |
|
296
|
2 |
|
public function sendAdminOrderMail(\Eccube\Entity\Order $Order, $formData) |
|
297
|
|
|
{ |
|
298
|
|
|
|
|
299
|
|
|
$body = $this->app->renderView('Mail/order.twig', array( |
|
300
|
2 |
|
'header' => $formData['header'], |
|
301
|
2 |
|
'footer' => $formData['footer'], |
|
302
|
|
|
'Order' => $Order, |
|
303
|
|
|
)); |
|
304
|
|
|
|
|
305
|
2 |
|
$message = \Swift_Message::newInstance() |
|
306
|
|
|
->setSubject('[' . $this->BaseInfo->getShopName() . '] ' . $formData['subject']) |
|
|
|
|
|
|
307
|
|
|
->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName())) |
|
308
|
|
|
->setTo(array($Order->getEmail())) |
|
309
|
|
|
->setBcc($this->BaseInfo->getEmail01()) |
|
310
|
|
|
->setReplyTo($this->BaseInfo->getEmail03()) |
|
311
|
|
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
312
|
|
|
->setBody($body); |
|
313
|
|
|
|
|
314
|
|
|
$event = new EventArgs( |
|
315
|
|
|
array( |
|
316
|
|
|
'message' => $message, |
|
317
|
|
|
'order' => $Order, |
|
318
|
|
|
'data' => $formData, |
|
319
|
2 |
|
'BaseInfo' => $this->BaseInfo, |
|
320
|
|
|
), |
|
321
|
2 |
|
$this->app['request'] |
|
322
|
|
|
); |
|
323
|
|
|
$this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_ADMIN_ORDER, $event); |
|
324
|
|
|
|
|
325
|
|
|
$this->app->mail($message); |
|
326
|
|
|
|
|
327
|
1 |
|
} |
|
328
|
|
|
|
|
329
|
|
|
/** |
|
|
|
|
|
|
330
|
|
|
* Send password reset notification mail. |
|
331
|
|
|
* |
|
332
|
|
|
* @param $Customer 会員情報 |
|
|
|
|
|
|
333
|
|
|
*/ |
|
334
|
2 |
View Code Duplication |
public function sendPasswordResetNotificationMail(\Eccube\Entity\Customer $Customer, $reset_url) |
|
|
|
|
|
|
335
|
|
|
{ |
|
336
|
|
|
$body = $this->app->renderView('Mail/forgot_mail.twig', array( |
|
|
|
|
|
|
337
|
|
|
'Customer' => $Customer, |
|
338
|
|
|
'reset_url' => $reset_url |
|
339
|
|
|
)); |
|
340
|
|
|
|
|
341
|
2 |
|
$message = \Swift_Message::newInstance() |
|
342
|
|
|
->setSubject('[' . $this->BaseInfo->getShopName() . '] パスワード変更のご確認') |
|
|
|
|
|
|
343
|
|
|
->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName())) |
|
344
|
|
|
->setTo(array($Customer->getEmail())) |
|
345
|
|
|
->setBcc($this->BaseInfo->getEmail01()) |
|
346
|
|
|
->setReplyTo($this->BaseInfo->getEmail03()) |
|
347
|
|
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
348
|
|
|
->setBody($body); |
|
349
|
|
|
|
|
350
|
|
|
$event = new EventArgs( |
|
351
|
|
|
array( |
|
352
|
|
|
'message' => $message, |
|
353
|
|
|
'Customer' => $Customer, |
|
354
|
2 |
|
'BaseInfo' => $this->BaseInfo, |
|
355
|
|
|
'resetUrl' => $reset_url, |
|
356
|
|
|
), |
|
357
|
2 |
|
$this->app['request'] |
|
358
|
|
|
); |
|
359
|
|
|
$this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_PASSWORD_RESET, $event); |
|
360
|
|
|
|
|
361
|
|
|
$this->app->mail($message); |
|
362
|
|
|
|
|
363
|
1 |
|
} |
|
364
|
|
|
|
|
365
|
|
|
/** |
|
|
|
|
|
|
366
|
|
|
* Send password reset notification mail. |
|
367
|
|
|
* |
|
368
|
|
|
* @param $Customer 会員情報 |
|
|
|
|
|
|
369
|
|
|
*/ |
|
370
|
2 |
View Code Duplication |
public function sendPasswordResetCompleteMail(\Eccube\Entity\Customer $Customer, $password) |
|
|
|
|
|
|
371
|
|
|
{ |
|
372
|
|
|
$body = $this->app->renderView('Mail/reset_complete_mail.twig', array( |
|
373
|
|
|
'Customer' => $Customer, |
|
374
|
|
|
'password' => $password, |
|
375
|
|
|
)); |
|
376
|
|
|
|
|
377
|
2 |
|
$message = \Swift_Message::newInstance() |
|
378
|
|
|
->setSubject('[' . $this->BaseInfo->getShopName() . '] パスワード変更のお知らせ') |
|
|
|
|
|
|
379
|
|
|
->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName())) |
|
380
|
|
|
->setTo(array($Customer->getEmail())) |
|
381
|
|
|
->setBcc($this->BaseInfo->getEmail01()) |
|
382
|
|
|
->setReplyTo($this->BaseInfo->getEmail03()) |
|
383
|
|
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
384
|
|
|
->setBody($body); |
|
385
|
|
|
|
|
386
|
|
|
$event = new EventArgs( |
|
387
|
|
|
array( |
|
388
|
|
|
'message' => $message, |
|
389
|
|
|
'Customer' => $Customer, |
|
390
|
2 |
|
'BaseInfo' => $this->BaseInfo, |
|
391
|
|
|
'password' => $password, |
|
392
|
|
|
), |
|
393
|
2 |
|
$this->app['request'] |
|
394
|
|
|
); |
|
395
|
|
|
$this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_PASSWORD_RESET_COMPLETE, $event); |
|
396
|
|
|
|
|
397
|
|
|
$this->app->mail($message); |
|
398
|
|
|
|
|
399
|
1 |
|
} |
|
400
|
|
|
|
|
401
|
|
|
} |
|
402
|
|
|
|