|
1
|
|
|
<?php |
|
2
|
|
|
namespace AliyunMNS\Model; |
|
3
|
|
|
|
|
4
|
|
|
use AliyunMNS\Constants; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Please refer to |
|
8
|
|
|
* https://docs.aliyun.com/?spm=#/pub/mns/api_reference/intro&intro |
|
9
|
|
|
* for more details |
|
10
|
|
|
*/ |
|
11
|
|
|
class MailAttributes |
|
12
|
|
|
{ |
|
13
|
|
|
public $subject; |
|
14
|
|
|
public $accountName; |
|
15
|
|
|
public $addressType; |
|
16
|
|
|
public $replyToAddress; |
|
17
|
|
|
public $isHtml; |
|
18
|
|
|
|
|
19
|
|
|
public function __construct( |
|
20
|
|
|
$subject, $accountName, $addressType=0, $replyToAddress=false, $isHtml = false) |
|
21
|
|
|
{ |
|
22
|
|
|
$this->subject = $subject; |
|
23
|
|
|
$this->accountName = $accountName; |
|
24
|
|
|
$this->addressType = $addressType; |
|
25
|
|
|
$this->replyToAddress = $replyToAddress; |
|
26
|
|
|
$this->isHtml = $isHtml; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function setSubject($subject) |
|
30
|
|
|
{ |
|
31
|
|
|
$this->subject = $subject; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function getSubject() |
|
35
|
|
|
{ |
|
36
|
|
|
return $this->subject; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function setAccountName($accountName) |
|
40
|
|
|
{ |
|
41
|
|
|
$this->accountName = $accountName; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function getAccountName() |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->accountName; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function setAddressType($addressType) |
|
50
|
|
|
{ |
|
51
|
|
|
$this->addressType = $addressType; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function getAddressType() |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->addressType; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function setReplyToAddress($replyToAddress) |
|
60
|
|
|
{ |
|
61
|
|
|
$this->replyToAddress = $replyToAddress; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function getReplyToAddress() |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->replyToAddress; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function setIsHtml($isHtml) |
|
70
|
|
|
{ |
|
71
|
|
|
$this->isHtml = $isHtml; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function getIsHtml() |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->isHtml; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function writeXML(\XMLWriter $xmlWriter) |
|
80
|
|
|
{ |
|
81
|
|
|
$jsonArray = array(); |
|
82
|
|
|
if ($this->subject !== NULL) |
|
83
|
|
|
{ |
|
84
|
|
|
$jsonArray[Constants::SUBJECT] = $this->subject; |
|
85
|
|
|
} |
|
86
|
|
|
if ($this->accountName !== NULL) |
|
87
|
|
|
{ |
|
88
|
|
|
$jsonArray[Constants::ACCOUNT_NAME] = $this->accountName; |
|
89
|
|
|
} |
|
90
|
|
|
if ($this->addressType !== NULL) |
|
91
|
|
|
{ |
|
92
|
|
|
$jsonArray[Constants::ADDRESS_TYPE] = $this->addressType; |
|
93
|
|
|
} |
|
94
|
|
|
else |
|
95
|
|
|
{ |
|
96
|
|
|
$jsonArray[Constants::ADDRESS_TYPE] = 0; |
|
97
|
|
|
} |
|
98
|
|
|
if ($this->replyToAddress !== NULL) |
|
99
|
|
|
{ |
|
100
|
|
|
if ($this->replyToAddress === TRUE) |
|
101
|
|
|
{ |
|
102
|
|
|
$jsonArray[Constants::REPLY_TO_ADDRESS] = "1"; |
|
103
|
|
|
} |
|
104
|
|
|
else |
|
105
|
|
|
{ |
|
106
|
|
|
$jsonArray[Constants::REPLY_TO_ADDRESS] = "0"; |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
if ($this->isHtml !== NULL) |
|
110
|
|
|
{ |
|
111
|
|
|
if ($this->isHtml === TRUE) |
|
112
|
|
|
{ |
|
113
|
|
|
$jsonArray[Constants::IS_HTML] = "1"; |
|
114
|
|
|
} |
|
115
|
|
|
else |
|
116
|
|
|
{ |
|
117
|
|
|
$jsonArray[Constants::IS_HTML] = "0"; |
|
118
|
|
|
} |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
if (!empty($jsonArray)) |
|
122
|
|
|
{ |
|
123
|
|
|
$xmlWriter->writeElement(Constants::DIRECT_MAIL, json_encode($jsonArray)); |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
?> |
|
129
|
|
|
|