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