|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of EC-CUBE |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright(c) LOCKON CO.,LTD. All Rights Reserved. |
|
7
|
|
|
* |
|
8
|
|
|
* http://www.lockon.co.jp/ |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Eccube\Service; |
|
15
|
|
|
|
|
16
|
|
|
use Eccube\Common\EccubeConfig; |
|
17
|
|
|
use Eccube\Entity\BaseInfo; |
|
18
|
|
|
use Eccube\Entity\Customer; |
|
19
|
|
|
use Eccube\Entity\MailHistory; |
|
20
|
|
|
use Eccube\Entity\MailTemplate; |
|
21
|
|
|
use Eccube\Entity\Order; |
|
22
|
|
|
use Eccube\Entity\OrderItem; |
|
23
|
|
|
use Eccube\Entity\Shipping; |
|
24
|
|
|
use Eccube\Event\EccubeEvents; |
|
25
|
|
|
use Eccube\Event\EventArgs; |
|
26
|
|
|
use Eccube\Repository\MailHistoryRepository; |
|
27
|
|
|
use Eccube\Repository\MailTemplateRepository; |
|
28
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcher; |
|
29
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
|
30
|
|
|
|
|
31
|
|
|
class MailService |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* @var \Swift_Mailer |
|
35
|
|
|
*/ |
|
36
|
|
|
protected $mailer; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var MailTemplateRepository |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $mailTemplateRepository; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @var MailHistoryRepository |
|
45
|
|
|
*/ |
|
46
|
|
|
private $mailHistoryRepository; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @var EventDispatcher |
|
50
|
|
|
*/ |
|
51
|
|
|
protected $eventDispatcher; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @var BaseInfo |
|
55
|
|
|
*/ |
|
56
|
|
|
protected $BaseInfo; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @var EccubeConfig |
|
60
|
|
|
*/ |
|
61
|
|
|
protected $eccubeConfig; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @var \Twig_Environment |
|
65
|
|
|
*/ |
|
66
|
|
|
protected $twig; |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* MailService constructor. |
|
70
|
|
|
* |
|
71
|
|
|
* @param \Swift_Mailer $mailer |
|
72
|
|
|
* @param MailTemplateRepository $mailTemplateRepository |
|
73
|
|
|
* @param MailHistoryRepository $mailHistoryRepository |
|
74
|
|
|
* @param BaseInfo $baseInfo |
|
75
|
|
|
* @param EventDispatcherInterface $eventDispatcher |
|
76
|
|
|
* @param \Twig_Environment $twig |
|
77
|
|
|
* @param EccubeConfig $eccubeConfig |
|
78
|
|
|
*/ |
|
79
|
138 |
|
public function __construct( |
|
80
|
|
|
\Swift_Mailer $mailer, |
|
81
|
|
|
MailTemplateRepository $mailTemplateRepository, |
|
82
|
|
|
MailHistoryRepository $mailHistoryRepository, |
|
83
|
|
|
BaseInfo $baseInfo, |
|
84
|
|
|
EventDispatcherInterface $eventDispatcher, |
|
85
|
|
|
\Twig_Environment $twig, |
|
86
|
|
|
EccubeConfig $eccubeConfig |
|
87
|
|
|
) { |
|
88
|
138 |
|
$this->mailer = $mailer; |
|
89
|
138 |
|
$this->mailTemplateRepository = $mailTemplateRepository; |
|
90
|
138 |
|
$this->mailHistoryRepository = $mailHistoryRepository; |
|
91
|
138 |
|
$this->BaseInfo = $baseInfo; |
|
92
|
138 |
|
$this->eventDispatcher = $eventDispatcher; |
|
|
|
|
|
|
93
|
138 |
|
$this->eccubeConfig = $eccubeConfig; |
|
94
|
138 |
|
$this->twig = $twig; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Send customer confirm mail. |
|
99
|
|
|
* |
|
100
|
|
|
* @param $Customer 会員情報 |
|
101
|
|
|
* @param string $activateUrl アクティベート用url |
|
102
|
|
|
*/ |
|
103
|
2 |
|
public function sendCustomerConfirmMail(\Eccube\Entity\Customer $Customer, $activateUrl) |
|
104
|
|
|
{ |
|
105
|
2 |
|
log_info('仮会員登録メール送信開始'); |
|
106
|
|
|
|
|
107
|
2 |
|
$MailTemplate = $this->mailTemplateRepository->find($this->eccubeConfig['eccube_entry_confirm_mail_template_id']); |
|
108
|
|
|
|
|
109
|
2 |
|
$body = $this->twig->render($MailTemplate->getFileName(), [ |
|
110
|
2 |
|
'header' => $MailTemplate->getMailHeader(), |
|
111
|
2 |
|
'footer' => $MailTemplate->getMailFooter(), |
|
112
|
2 |
|
'Customer' => $Customer, |
|
113
|
2 |
|
'BaseInfo' => $this->BaseInfo, |
|
114
|
2 |
|
'activateUrl' => $activateUrl, |
|
115
|
|
|
]); |
|
116
|
|
|
|
|
117
|
2 |
|
$message = (new \Swift_Message()) |
|
118
|
2 |
|
->setSubject('['.$this->BaseInfo->getShopName().'] '.$MailTemplate->getMailSubject()) |
|
119
|
2 |
|
->setFrom([$this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()]) |
|
120
|
2 |
|
->setTo([$Customer->getEmail()]) |
|
121
|
2 |
|
->setBcc($this->BaseInfo->getEmail01()) |
|
122
|
2 |
|
->setReplyTo($this->BaseInfo->getEmail03()) |
|
123
|
2 |
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
124
|
2 |
|
->setBody($body); |
|
125
|
|
|
|
|
126
|
2 |
|
$event = new EventArgs( |
|
127
|
|
|
[ |
|
128
|
2 |
|
'message' => $message, |
|
129
|
2 |
|
'Customer' => $Customer, |
|
130
|
2 |
|
'BaseInfo' => $this->BaseInfo, |
|
131
|
2 |
|
'activateUrl' => $activateUrl, |
|
132
|
|
|
], |
|
133
|
2 |
|
null |
|
134
|
|
|
); |
|
135
|
2 |
|
$this->eventDispatcher->dispatch(EccubeEvents::MAIL_CUSTOMER_CONFIRM, $event); |
|
136
|
|
|
|
|
137
|
2 |
|
$count = $this->mailer->send($message, $failures); |
|
138
|
|
|
|
|
139
|
2 |
|
log_info('仮会員登録メール送信完了', ['count' => $count]); |
|
140
|
|
|
|
|
141
|
2 |
|
return $count; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* Send customer complete mail. |
|
146
|
|
|
* |
|
147
|
|
|
* @param $Customer 会員情報 |
|
148
|
|
|
*/ |
|
149
|
2 |
View Code Duplication |
public function sendCustomerCompleteMail(\Eccube\Entity\Customer $Customer) |
|
|
|
|
|
|
150
|
|
|
{ |
|
151
|
2 |
|
log_info('会員登録完了メール送信開始'); |
|
152
|
|
|
|
|
153
|
2 |
|
$MailTemplate = $this->mailTemplateRepository->find($this->eccubeConfig['eccube_entry_complete_mail_template_id']); |
|
154
|
|
|
|
|
155
|
2 |
|
$body = $this->twig->render($MailTemplate->getFileName(), [ |
|
156
|
2 |
|
'header' => $MailTemplate->getMailHeader(), |
|
157
|
2 |
|
'footer' => $MailTemplate->getMailFooter(), |
|
158
|
2 |
|
'Customer' => $Customer, |
|
159
|
2 |
|
'BaseInfo' => $this->BaseInfo, |
|
160
|
|
|
]); |
|
161
|
|
|
|
|
162
|
2 |
|
$message = (new \Swift_Message()) |
|
163
|
2 |
|
->setSubject('['.$this->BaseInfo->getShopName().'] '.$MailTemplate->getMailSubject()) |
|
164
|
2 |
|
->setFrom([$this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()]) |
|
165
|
2 |
|
->setTo([$Customer->getEmail()]) |
|
166
|
2 |
|
->setBcc($this->BaseInfo->getEmail01()) |
|
167
|
2 |
|
->setReplyTo($this->BaseInfo->getEmail03()) |
|
168
|
2 |
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
169
|
2 |
|
->setBody($body); |
|
170
|
|
|
|
|
171
|
2 |
|
$event = new EventArgs( |
|
172
|
|
|
[ |
|
173
|
2 |
|
'message' => $message, |
|
174
|
2 |
|
'Customer' => $Customer, |
|
175
|
2 |
|
'BaseInfo' => $this->BaseInfo, |
|
176
|
|
|
], |
|
177
|
2 |
|
null |
|
178
|
|
|
); |
|
179
|
2 |
|
$this->eventDispatcher->dispatch(EccubeEvents::MAIL_CUSTOMER_COMPLETE, $event); |
|
180
|
|
|
|
|
181
|
2 |
|
$count = $this->mailer->send($message); |
|
182
|
|
|
|
|
183
|
2 |
|
log_info('会員登録完了メール送信完了', ['count' => $count]); |
|
184
|
|
|
|
|
185
|
2 |
|
return $count; |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
/** |
|
189
|
|
|
* Send withdraw mail. |
|
190
|
|
|
* |
|
191
|
|
|
* @param $Customer Customer |
|
192
|
|
|
* @param $email string |
|
193
|
|
|
*/ |
|
194
|
2 |
View Code Duplication |
public function sendCustomerWithdrawMail(Customer $Customer, string $email) |
|
|
|
|
|
|
195
|
|
|
{ |
|
196
|
2 |
|
log_info('退会手続き完了メール送信開始'); |
|
197
|
|
|
|
|
198
|
2 |
|
$MailTemplate = $this->mailTemplateRepository->find($this->eccubeConfig['eccube_customer_withdraw_mail_template_id']); |
|
199
|
|
|
|
|
200
|
2 |
|
$body = $this->twig->render($MailTemplate->getFileName(), [ |
|
201
|
2 |
|
'header' => $MailTemplate->getMailHeader(), |
|
202
|
2 |
|
'footer' => $MailTemplate->getMailFooter(), |
|
203
|
2 |
|
'Customer' => $Customer, |
|
204
|
2 |
|
'BaseInfo' => $this->BaseInfo, |
|
205
|
|
|
]); |
|
206
|
|
|
|
|
207
|
2 |
|
$message = (new \Swift_Message()) |
|
208
|
2 |
|
->setSubject('['.$this->BaseInfo->getShopName().'] '.$MailTemplate->getMailSubject()) |
|
209
|
2 |
|
->setFrom([$this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()]) |
|
210
|
2 |
|
->setTo([$email]) |
|
211
|
2 |
|
->setBcc($this->BaseInfo->getEmail01()) |
|
212
|
2 |
|
->setReplyTo($this->BaseInfo->getEmail03()) |
|
213
|
2 |
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
214
|
2 |
|
->setBody($body); |
|
215
|
|
|
|
|
216
|
2 |
|
$event = new EventArgs( |
|
217
|
|
|
[ |
|
218
|
2 |
|
'message' => $message, |
|
219
|
2 |
|
'Customer' => $Customer, |
|
220
|
2 |
|
'BaseInfo' => $this->BaseInfo, |
|
221
|
2 |
|
'email' => $email, |
|
222
|
|
|
], |
|
223
|
2 |
|
null |
|
224
|
|
|
); |
|
225
|
2 |
|
$this->eventDispatcher->dispatch(EccubeEvents::MAIL_CUSTOMER_WITHDRAW, $event); |
|
226
|
|
|
|
|
227
|
2 |
|
$count = $this->mailer->send($message); |
|
228
|
|
|
|
|
229
|
2 |
|
log_info('退会手続き完了メール送信完了', ['count' => $count]); |
|
230
|
|
|
|
|
231
|
2 |
|
return $count; |
|
232
|
|
|
} |
|
233
|
|
|
|
|
234
|
|
|
/** |
|
235
|
|
|
* Send contact mail. |
|
236
|
|
|
* |
|
237
|
|
|
* @param $formData お問い合わせ内容 |
|
238
|
|
|
*/ |
|
239
|
4 |
View Code Duplication |
public function sendContactMail($formData) |
|
|
|
|
|
|
240
|
|
|
{ |
|
241
|
4 |
|
log_info('お問い合わせ受付メール送信開始'); |
|
242
|
|
|
|
|
243
|
4 |
|
$MailTemplate = $this->mailTemplateRepository->find($this->eccubeConfig['eccube_contact_mail_template_id']); |
|
244
|
|
|
|
|
245
|
4 |
|
$body = $this->twig->render($MailTemplate->getFileName(), [ |
|
246
|
4 |
|
'header' => $MailTemplate->getMailHeader(), |
|
247
|
4 |
|
'footer' => $MailTemplate->getMailFooter(), |
|
248
|
4 |
|
'data' => $formData, |
|
249
|
4 |
|
'BaseInfo' => $this->BaseInfo, |
|
250
|
|
|
]); |
|
251
|
|
|
|
|
252
|
|
|
// 問い合わせ者にメール送信 |
|
253
|
4 |
|
$message = (new \Swift_Message()) |
|
254
|
4 |
|
->setSubject('['.$this->BaseInfo->getShopName().'] '.$MailTemplate->getMailSubject()) |
|
255
|
4 |
|
->setFrom([$this->BaseInfo->getEmail02() => $this->BaseInfo->getShopName()]) |
|
256
|
4 |
|
->setTo([$formData['email']]) |
|
257
|
4 |
|
->setBcc($this->BaseInfo->getEmail02()) |
|
258
|
4 |
|
->setReplyTo($this->BaseInfo->getEmail02()) |
|
259
|
4 |
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
260
|
4 |
|
->setBody($body); |
|
261
|
|
|
|
|
262
|
4 |
|
$event = new EventArgs( |
|
263
|
|
|
[ |
|
264
|
4 |
|
'message' => $message, |
|
265
|
4 |
|
'formData' => $formData, |
|
266
|
4 |
|
'BaseInfo' => $this->BaseInfo, |
|
267
|
|
|
], |
|
268
|
4 |
|
null |
|
269
|
|
|
); |
|
270
|
4 |
|
$this->eventDispatcher->dispatch(EccubeEvents::MAIL_CONTACT, $event); |
|
271
|
|
|
|
|
272
|
4 |
|
$count = $this->mailer->send($message); |
|
273
|
|
|
|
|
274
|
4 |
|
log_info('お問い合わせ受付メール送信完了', ['count' => $count]); |
|
275
|
|
|
|
|
276
|
4 |
|
return $count; |
|
277
|
|
|
} |
|
278
|
|
|
|
|
279
|
|
|
/** |
|
280
|
|
|
* Alias of sendContactMail(). |
|
281
|
|
|
* |
|
282
|
|
|
* @param $formData お問い合わせ内容 |
|
283
|
|
|
* |
|
284
|
|
|
* @see sendContactMail() |
|
285
|
|
|
* @deprecated since 3.0.0, to be removed in 3.1 |
|
286
|
|
|
* @see https://github.com/EC-CUBE/ec-cube/issues/1315 |
|
287
|
|
|
*/ |
|
288
|
|
|
public function sendrContactMail($formData) |
|
289
|
|
|
{ |
|
290
|
|
|
$this->sendContactMail($formData); |
|
291
|
|
|
} |
|
292
|
|
|
|
|
293
|
|
|
/** |
|
294
|
|
|
* Send order mail. |
|
295
|
|
|
* |
|
296
|
|
|
* @param \Eccube\Entity\Order $Order 受注情報 |
|
297
|
|
|
* |
|
298
|
|
|
* @return \Swift_Message |
|
299
|
|
|
*/ |
|
300
|
7 |
View Code Duplication |
public function sendOrderMail(\Eccube\Entity\Order $Order) |
|
|
|
|
|
|
301
|
|
|
{ |
|
302
|
7 |
|
log_info('受注メール送信開始'); |
|
303
|
|
|
|
|
304
|
7 |
|
$MailTemplate = $this->mailTemplateRepository->find($this->eccubeConfig['eccube_order_mail_template_id']); |
|
305
|
|
|
|
|
306
|
7 |
|
$body = $this->twig->render($MailTemplate->getFileName(), [ |
|
307
|
7 |
|
'header' => $MailTemplate->getMailHeader(), |
|
308
|
7 |
|
'footer' => $MailTemplate->getMailFooter(), |
|
309
|
7 |
|
'Order' => $Order, |
|
310
|
|
|
]); |
|
311
|
|
|
|
|
312
|
7 |
|
$message = (new \Swift_Message()) |
|
313
|
7 |
|
->setSubject('['.$this->BaseInfo->getShopName().'] '.$MailTemplate->getMailSubject()) |
|
314
|
7 |
|
->setFrom([$this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()]) |
|
315
|
7 |
|
->setTo([$Order->getEmail()]) |
|
316
|
7 |
|
->setBcc($this->BaseInfo->getEmail01()) |
|
317
|
7 |
|
->setReplyTo($this->BaseInfo->getEmail03()) |
|
318
|
7 |
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
319
|
7 |
|
->setBody($body); |
|
320
|
|
|
|
|
321
|
7 |
|
$event = new EventArgs( |
|
322
|
|
|
[ |
|
323
|
7 |
|
'message' => $message, |
|
324
|
7 |
|
'Order' => $Order, |
|
325
|
7 |
|
'MailTemplate' => $MailTemplate, |
|
326
|
7 |
|
'BaseInfo' => $this->BaseInfo, |
|
327
|
|
|
], |
|
328
|
7 |
|
null |
|
329
|
|
|
); |
|
330
|
7 |
|
$this->eventDispatcher->dispatch(EccubeEvents::MAIL_ORDER, $event); |
|
331
|
|
|
|
|
332
|
7 |
|
$count = $this->mailer->send($message); |
|
333
|
|
|
|
|
334
|
7 |
|
log_info('受注メール送信完了', ['count' => $count]); |
|
335
|
|
|
|
|
336
|
7 |
|
return $message; |
|
337
|
|
|
} |
|
338
|
|
|
|
|
339
|
|
|
/** |
|
340
|
|
|
* Send admin customer confirm mail. |
|
341
|
|
|
* |
|
342
|
|
|
* @param $Customer 会員情報 |
|
343
|
|
|
* @param string $activateUrl アクティベート用url |
|
344
|
|
|
*/ |
|
345
|
2 |
|
public function sendAdminCustomerConfirmMail(\Eccube\Entity\Customer $Customer, $activateUrl) |
|
346
|
|
|
{ |
|
347
|
2 |
|
log_info('仮会員登録再送メール送信開始'); |
|
348
|
|
|
|
|
349
|
|
|
/* @var $MailTemplate \Eccube\Entity\MailTemplate */ |
|
350
|
2 |
|
$MailTemplate = $this->mailTemplateRepository->find($this->eccubeConfig['eccube_entry_confirm_mail_template_id']); |
|
351
|
|
|
|
|
352
|
2 |
|
$body = $this->twig->render($MailTemplate->getFileName(), [ |
|
353
|
2 |
|
'header' => $MailTemplate->getMailHeader(), |
|
354
|
2 |
|
'footer' => $MailTemplate->getMailFooter(), |
|
355
|
2 |
|
'BaseInfo' => $this->BaseInfo, |
|
356
|
2 |
|
'Customer' => $Customer, |
|
357
|
2 |
|
'activateUrl' => $activateUrl, |
|
358
|
|
|
]); |
|
359
|
|
|
|
|
360
|
2 |
|
$message = (new \Swift_Message()) |
|
361
|
2 |
|
->setSubject('['.$this->BaseInfo->getShopName().'] '.$MailTemplate->getMailSubject()) |
|
362
|
2 |
|
->setFrom([$this->BaseInfo->getEmail03() => $this->BaseInfo->getShopName()]) |
|
363
|
2 |
|
->setTo([$Customer->getEmail()]) |
|
364
|
2 |
|
->setBcc($this->BaseInfo->getEmail01()) |
|
365
|
2 |
|
->setReplyTo($this->BaseInfo->getEmail03()) |
|
366
|
2 |
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
367
|
2 |
|
->setBody($body); |
|
368
|
|
|
|
|
369
|
2 |
|
$event = new EventArgs( |
|
370
|
|
|
[ |
|
371
|
2 |
|
'message' => $message, |
|
372
|
2 |
|
'Customer' => $Customer, |
|
373
|
2 |
|
'BaseInfo' => $this->BaseInfo, |
|
374
|
2 |
|
'activateUrl' => $activateUrl, |
|
375
|
|
|
], |
|
376
|
2 |
|
null |
|
377
|
|
|
); |
|
378
|
2 |
|
$this->eventDispatcher->dispatch(EccubeEvents::MAIL_ADMIN_CUSTOMER_CONFIRM, $event); |
|
379
|
|
|
|
|
380
|
2 |
|
$count = $this->mailer->send($message); |
|
381
|
|
|
|
|
382
|
2 |
|
log_info('仮会員登録再送メール送信完了', ['count' => $count]); |
|
383
|
|
|
|
|
384
|
2 |
|
return $count; |
|
385
|
|
|
} |
|
386
|
|
|
|
|
387
|
|
|
/** |
|
388
|
|
|
* Send admin order mail. |
|
389
|
|
|
* |
|
390
|
|
|
* @param Order $Order 受注情報 |
|
391
|
|
|
* @param $formData 入力内容 |
|
392
|
|
|
* @param string $twig テンプレートファイル名 |
|
393
|
|
|
* |
|
394
|
|
|
* @return \Swift_Message |
|
395
|
|
|
* |
|
396
|
|
|
* @throws \Twig_Error_Loader |
|
397
|
|
|
* @throws \Twig_Error_Runtime |
|
398
|
|
|
* @throws \Twig_Error_Syntax |
|
399
|
|
|
*/ |
|
400
|
3 |
|
public function sendAdminOrderMail(Order $Order, $formData, $twig = '@admin/Mail/order.twig') |
|
401
|
|
|
{ |
|
402
|
3 |
|
log_info('受注管理通知メール送信開始'); |
|
403
|
|
|
|
|
404
|
3 |
|
$body = $this->twig->render($twig, [ |
|
405
|
3 |
|
'header' => $formData['mail_header'], |
|
406
|
3 |
|
'footer' => $formData['mail_footer'], |
|
407
|
3 |
|
'Order' => $Order, |
|
408
|
|
|
]); |
|
409
|
|
|
|
|
410
|
3 |
|
$message = (new \Swift_Message()) |
|
411
|
3 |
|
->setSubject('['.$this->BaseInfo->getShopName().'] '.$formData['mail_subject']) |
|
412
|
3 |
|
->setFrom([$this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()]) |
|
413
|
3 |
|
->setTo([$Order->getEmail()]) |
|
414
|
3 |
|
->setBcc($this->BaseInfo->getEmail01()) |
|
415
|
3 |
|
->setReplyTo($this->BaseInfo->getEmail03()) |
|
416
|
3 |
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
417
|
3 |
|
->setBody($body); |
|
418
|
|
|
|
|
419
|
3 |
|
$event = new EventArgs( |
|
420
|
|
|
[ |
|
421
|
3 |
|
'message' => $message, |
|
422
|
3 |
|
'Order' => $Order, |
|
423
|
3 |
|
'formData' => $formData, |
|
424
|
3 |
|
'BaseInfo' => $this->BaseInfo, |
|
425
|
|
|
], |
|
426
|
3 |
|
null |
|
427
|
|
|
); |
|
428
|
3 |
|
$this->eventDispatcher->dispatch(EccubeEvents::MAIL_ADMIN_ORDER, $event); |
|
429
|
|
|
|
|
430
|
3 |
|
$count = $this->mailer->send($message); |
|
431
|
|
|
|
|
432
|
3 |
|
log_info('受注管理通知メール送信完了', ['count' => $count]); |
|
433
|
|
|
|
|
434
|
3 |
|
return $message; |
|
435
|
|
|
} |
|
436
|
|
|
|
|
437
|
|
|
/** |
|
438
|
|
|
* Send password reset notification mail. |
|
439
|
|
|
* |
|
440
|
|
|
* @param $Customer 会員情報 |
|
441
|
|
|
* @param string $reset_url |
|
442
|
|
|
*/ |
|
443
|
1 |
|
public function sendPasswordResetNotificationMail(\Eccube\Entity\Customer $Customer, $reset_url) |
|
444
|
|
|
{ |
|
445
|
1 |
|
log_info('パスワード再発行メール送信開始'); |
|
446
|
|
|
|
|
447
|
1 |
|
$MailTemplate = $this->mailTemplateRepository->find($this->eccubeConfig['eccube_forgot_mail_template_id']); |
|
448
|
1 |
|
$body = $this->twig->render($MailTemplate->getFileName(), [ |
|
449
|
1 |
|
'BaseInfo' => $this->BaseInfo, |
|
450
|
1 |
|
'header' => $MailTemplate->getMailHeader(), |
|
451
|
1 |
|
'footer' => $MailTemplate->getMailFooter(), |
|
452
|
1 |
|
'Customer' => $Customer, |
|
453
|
1 |
|
'expire' => $this->eccubeConfig['eccube_customer_reset_expire'], |
|
454
|
1 |
|
'reset_url' => $reset_url, |
|
455
|
|
|
]); |
|
456
|
|
|
|
|
457
|
1 |
|
$message = (new \Swift_Message()) |
|
458
|
1 |
|
->setSubject('['.$this->BaseInfo->getShopName().'] '.$MailTemplate->getMailSubject()) |
|
459
|
1 |
|
->setFrom([$this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()]) |
|
460
|
1 |
|
->setTo([$Customer->getEmail()]) |
|
461
|
1 |
|
->setReplyTo($this->BaseInfo->getEmail03()) |
|
462
|
1 |
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
463
|
1 |
|
->setBody($body); |
|
464
|
|
|
|
|
465
|
1 |
|
$event = new EventArgs( |
|
466
|
|
|
[ |
|
467
|
1 |
|
'message' => $message, |
|
468
|
1 |
|
'Customer' => $Customer, |
|
469
|
1 |
|
'BaseInfo' => $this->BaseInfo, |
|
470
|
1 |
|
'resetUrl' => $reset_url, |
|
471
|
|
|
], |
|
472
|
1 |
|
null |
|
473
|
|
|
); |
|
474
|
1 |
|
$this->eventDispatcher->dispatch(EccubeEvents::MAIL_PASSWORD_RESET, $event); |
|
475
|
|
|
|
|
476
|
1 |
|
$count = $this->mailer->send($message); |
|
477
|
|
|
|
|
478
|
1 |
|
log_info('パスワード再発行メール送信完了', ['count' => $count]); |
|
479
|
|
|
|
|
480
|
1 |
|
return $count; |
|
481
|
|
|
} |
|
482
|
|
|
|
|
483
|
|
|
/** |
|
484
|
|
|
* Send password reset notification mail. |
|
485
|
|
|
* |
|
486
|
|
|
* @param $Customer 会員情報 |
|
487
|
|
|
* @param string $password |
|
488
|
|
|
*/ |
|
489
|
1 |
|
public function sendPasswordResetCompleteMail(\Eccube\Entity\Customer $Customer, $password) |
|
490
|
|
|
{ |
|
491
|
1 |
|
log_info('パスワード変更完了メール送信開始'); |
|
492
|
|
|
|
|
493
|
1 |
|
$MailTemplate = $this->mailTemplateRepository->find($this->eccubeConfig['eccube_reset_complete_mail_template_id']); |
|
494
|
|
|
|
|
495
|
1 |
|
$body = $this->twig->render($MailTemplate->getFileName(), [ |
|
496
|
1 |
|
'BaseInfo' => $this->BaseInfo, |
|
497
|
1 |
|
'header' => $MailTemplate->getMailHeader(), |
|
498
|
1 |
|
'footer' => $MailTemplate->getMailFooter(), |
|
499
|
1 |
|
'Customer' => $Customer, |
|
500
|
1 |
|
'password' => $password, |
|
501
|
|
|
]); |
|
502
|
|
|
|
|
503
|
1 |
|
$message = (new \Swift_Message()) |
|
504
|
1 |
|
->setSubject('['.$this->BaseInfo->getShopName().'] '.$MailTemplate->getMailSubject()) |
|
505
|
1 |
|
->setFrom([$this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()]) |
|
506
|
1 |
|
->setTo([$Customer->getEmail()]) |
|
507
|
1 |
|
->setBcc($this->BaseInfo->getEmail01()) |
|
508
|
1 |
|
->setReplyTo($this->BaseInfo->getEmail03()) |
|
509
|
1 |
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
510
|
1 |
|
->setBody($body); |
|
511
|
|
|
|
|
512
|
1 |
|
$event = new EventArgs( |
|
513
|
|
|
[ |
|
514
|
1 |
|
'message' => $message, |
|
515
|
1 |
|
'Customer' => $Customer, |
|
516
|
1 |
|
'BaseInfo' => $this->BaseInfo, |
|
517
|
1 |
|
'password' => $password, |
|
518
|
|
|
], |
|
519
|
1 |
|
null |
|
520
|
|
|
); |
|
521
|
1 |
|
$this->eventDispatcher->dispatch(EccubeEvents::MAIL_PASSWORD_RESET_COMPLETE, $event); |
|
522
|
|
|
|
|
523
|
1 |
|
$count = $this->mailer->send($message); |
|
524
|
|
|
|
|
525
|
1 |
|
log_info('パスワード変更完了メール送信完了', ['count' => $count]); |
|
526
|
|
|
|
|
527
|
1 |
|
return $count; |
|
528
|
|
|
} |
|
529
|
|
|
|
|
530
|
|
|
/** |
|
531
|
|
|
* ポイントでマイナス発生時にメール通知する。 |
|
532
|
|
|
* |
|
533
|
|
|
* @param Order $Order |
|
534
|
|
|
* @param int $currentPoint |
|
535
|
|
|
* @param int $changePoint |
|
536
|
|
|
*/ |
|
537
|
|
|
public function sendPointNotifyMail(\Eccube\Entity\Order $Order, $currentPoint = 0, $changePoint = 0) |
|
538
|
|
|
{ |
|
539
|
|
|
$body = $this->twig->render('Mail/point_notify.twig', [ |
|
540
|
|
|
'Order' => $Order, |
|
541
|
|
|
'currentPoint' => $currentPoint, |
|
542
|
|
|
'changePoint' => $changePoint, |
|
543
|
|
|
]); |
|
544
|
|
|
|
|
545
|
|
|
$message = (new \Swift_Message()) |
|
546
|
|
|
->setSubject('['.$this->BaseInfo->getShopName().'] ポイント通知') |
|
547
|
|
|
->setFrom([$this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()]) |
|
548
|
|
|
->setTo([$this->BaseInfo->getEmail01()]) |
|
549
|
|
|
->setBcc($this->BaseInfo->getEmail01()) |
|
550
|
|
|
->setReplyTo($this->BaseInfo->getEmail03()) |
|
551
|
|
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
552
|
|
|
->setBody($body); |
|
553
|
|
|
|
|
554
|
|
|
$this->mailer->send($message); |
|
555
|
|
|
} |
|
556
|
|
|
|
|
557
|
|
|
/** |
|
558
|
|
|
* 発送通知メールを送信する. |
|
559
|
|
|
* 発送通知メールは受注ごとに送られる |
|
560
|
|
|
* |
|
561
|
|
|
* @param Shipping $Shipping |
|
562
|
|
|
* |
|
563
|
|
|
* @throws \Twig_Error |
|
564
|
|
|
*/ |
|
565
|
4 |
|
public function sendShippingNotifyMail(Shipping $Shipping) |
|
566
|
|
|
{ |
|
567
|
4 |
|
log_info('出荷通知メール送信処理開始', ['id' => $Shipping->getId()]); |
|
568
|
|
|
|
|
569
|
4 |
|
$MailTemplate = $this->mailTemplateRepository->find($this->eccubeConfig['eccube_shipping_notify_mail_template_id']); |
|
570
|
|
|
|
|
571
|
|
|
/** @var Order $Order */ |
|
572
|
4 |
|
$Order = $Shipping->getOrder(); |
|
573
|
4 |
|
$message = (new \Swift_Message()) |
|
574
|
4 |
|
->setSubject('['.$this->BaseInfo->getShopName().'] '.$MailTemplate->getMailSubject()) |
|
575
|
4 |
|
->setFrom([$this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()]) |
|
576
|
4 |
|
->setTo($Order->getEmail()) |
|
577
|
4 |
|
->setBcc($this->BaseInfo->getEmail01()) |
|
578
|
4 |
|
->setReplyTo($this->BaseInfo->getEmail03()) |
|
579
|
4 |
|
->setReturnPath($this->BaseInfo->getEmail04()) |
|
580
|
4 |
|
->setBody($this->getShippingNotifyMailBody($Shipping, $Order, $MailTemplate)); |
|
|
|
|
|
|
581
|
|
|
|
|
582
|
4 |
|
$this->mailer->send($message); |
|
583
|
|
|
|
|
584
|
4 |
|
$MailHistory = new MailHistory(); |
|
585
|
4 |
|
$MailHistory->setMailSubject($message->getSubject()) |
|
586
|
4 |
|
->setMailBody($message->getBody()) |
|
587
|
4 |
|
->setOrder($Order) |
|
588
|
4 |
|
->setSendDate(new \DateTime()); |
|
589
|
|
|
|
|
590
|
4 |
|
$this->mailHistoryRepository->save($MailHistory); |
|
591
|
|
|
|
|
592
|
4 |
|
log_info('出荷通知メール送信処理完了', ['id' => $Shipping->getId()]); |
|
593
|
|
|
} |
|
594
|
|
|
|
|
595
|
|
|
/** |
|
596
|
|
|
* @param Shipping $Shipping |
|
597
|
|
|
* @param Order $Order |
|
598
|
|
|
* @param MailTemplate|null $MailTemplate |
|
599
|
|
|
* |
|
600
|
|
|
* @return string |
|
601
|
|
|
* |
|
602
|
|
|
* @throws \Twig_Error |
|
603
|
|
|
*/ |
|
604
|
|
|
public function getShippingNotifyMailBody(Shipping $Shipping, Order $Order, MailTemplate $MailTemplate = null) |
|
605
|
|
|
{ |
|
606
|
4 |
|
$ShippingItems = array_filter($Shipping->getOrderItems()->toArray(), function (OrderItem $OrderItem) use ($Order) { |
|
607
|
4 |
|
return $OrderItem->getOrderId() === $Order->getId(); |
|
608
|
4 |
|
}); |
|
609
|
|
|
|
|
610
|
|
|
/** @var MailTemplate $MailTemplate */ |
|
611
|
4 |
|
$MailTemplate = $MailTemplate ?? $this->mailTemplateRepository->find($this->eccubeConfig['eccube_shipping_notify_mail_template_id']); |
|
612
|
|
|
|
|
613
|
4 |
|
return $this->twig->render($MailTemplate->getFileName(), [ |
|
614
|
4 |
|
'Shipping' => $Shipping, |
|
615
|
4 |
|
'ShippingItems' => $ShippingItems, |
|
616
|
4 |
|
'header' => $MailTemplate->getMailHeader(), |
|
617
|
4 |
|
'footer' => $MailTemplate->getMailFooter(), |
|
618
|
|
|
]); |
|
619
|
|
|
} |
|
620
|
|
|
} |
|
621
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.