File tree Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © 2016 Magento. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ namespace Magento \Email \Model \Plugin ;
7
+
8
+ /**
9
+ * Plugin for \Magento\Framework\Mail\TransportInterface
10
+ */
11
+ class WindowsSmtpConfig
12
+ {
13
+ /**
14
+ * host config path
15
+ */
16
+ const XML_SMTP_HOST = 'system/smtp/host ' ;
17
+
18
+ /**
19
+ * port config path
20
+ */
21
+ const XML_SMTP_PORT = 'system/smtp/port ' ;
22
+
23
+ /**
24
+ * @var \Magento\Framework\App\Config\ReinitableConfigInterface
25
+ */
26
+ private $ config ;
27
+
28
+ /**
29
+ * @var \Magento\Framework\OsInfo
30
+ */
31
+ private $ osInfo ;
32
+
33
+ /**
34
+ * @param \Magento\Framework\App\Config\ReinitableConfigInterface $config
35
+ * @param \Magento\Framework\OsInfo $osInfo
36
+ */
37
+ public function __construct (
38
+ \Magento \Framework \App \Config \ReinitableConfigInterface $ config ,
39
+ \Magento \Framework \OsInfo $ osInfo
40
+ ) {
41
+ $ this ->config = $ config ;
42
+ $ this ->osInfo = $ osInfo ;
43
+ }
44
+
45
+ /**
46
+ * To configure smtp settings for session right before sending message on windows server
47
+ *
48
+ * @param \Magento\Framework\Mail\TransportInterface $subject
49
+ * return void
50
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
51
+ */
52
+ public function beforeSendMessage (\Magento \Framework \Mail \TransportInterface $ subject )
53
+ {
54
+ if ($ this ->osInfo ->isWindows ()) {
55
+ ini_set ('SMTP ' , $ this ->config ->getValue (self ::XML_SMTP_HOST ));
56
+ ini_set ('smtp_port ' , $ this ->config ->getValue (self ::XML_SMTP_PORT ));
57
+ }
58
+ }
59
+ }
Original file line number Diff line number Diff line change 57
57
</argument >
58
58
</arguments >
59
59
</type >
60
+ <type name =" Magento\Framework\Mail\TransportInterface" >
61
+ <plugin name =" WindowsSmtpConfig" type =" Magento\Email\Model\Plugin\WindowsSmtpConfig" />
62
+ </type >
60
63
</config >
You can’t perform that action at this time.
0 commit comments