1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2013 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2014-2018 |
7
|
|
|
* @package MW |
8
|
|
|
* @subpackage Mail |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
namespace Aimeos\MW\Mail\Message; |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Zend implementation for creating e-mails. |
17
|
|
|
* |
18
|
|
|
* @package MW |
19
|
|
|
* @subpackage Mail |
20
|
|
|
*/ |
21
|
|
|
class Zend implements \Aimeos\MW\Mail\Message\Iface |
22
|
|
|
{ |
23
|
|
|
private $object; |
24
|
|
|
private $embedded = []; |
25
|
|
|
private $html; |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Initializes the message instance. |
30
|
|
|
* |
31
|
|
|
* @param \Zend_Mail $object Zend mail object |
32
|
|
|
*/ |
33
|
|
|
public function __construct( \Zend_Mail $object ) |
|
|
|
|
34
|
|
|
{ |
35
|
|
|
$this->object = $object; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Adds a source e-mail address of the message. |
41
|
|
|
* |
42
|
|
|
* @param string $email Source e-mail address |
43
|
|
|
* @param string|null $name Name of the user sending the e-mail or null for no name |
44
|
|
|
* @return \Aimeos\MW\Mail\Message\Iface Message object |
45
|
|
|
*/ |
46
|
|
|
public function addFrom( $email, $name = null ) |
47
|
|
|
{ |
48
|
|
|
$this->object->setFrom( $email, $name ); |
49
|
|
|
return $this; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Adds a destination e-mail address of the target user mailbox. |
55
|
|
|
* |
56
|
|
|
* @param string $email Destination address of the target mailbox |
57
|
|
|
* @param string|null $name Name of the user owning the target mailbox or null for no name |
58
|
|
|
* @return \Aimeos\MW\Mail\Message\Iface Message object |
59
|
|
|
*/ |
60
|
|
|
public function addTo( $email, $name = null ) |
61
|
|
|
{ |
62
|
|
|
$this->object->addTo( $email, $name ); |
63
|
|
|
return $this; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Adds a destination e-mail address for a copy of the message. |
69
|
|
|
* |
70
|
|
|
* @param string $email Destination address for a copy |
71
|
|
|
* @param string|null $name Name of the user owning the target mailbox or null for no name |
72
|
|
|
* @return \Aimeos\MW\Mail\Message\Iface Message object |
73
|
|
|
*/ |
74
|
|
|
public function addCc( $email, $name = null ) |
75
|
|
|
{ |
76
|
|
|
$this->object->addCc( $email, $name ); |
77
|
|
|
return $this; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Adds a destination e-mail address for a hidden copy of the message. |
83
|
|
|
* |
84
|
|
|
* @param string $email Destination address for a hidden copy |
85
|
|
|
* @param string|null $name Name of the user owning the target mailbox or null for no name |
86
|
|
|
* @return \Aimeos\MW\Mail\Message\Iface Message object |
87
|
|
|
*/ |
88
|
|
|
public function addBcc( $email, $name = null ) |
89
|
|
|
{ |
90
|
|
|
$this->object->addBcc( $email, $name ); |
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Adds the return e-mail address for the message. |
97
|
|
|
* |
98
|
|
|
* @param string $email E-mail address which should receive all replies |
99
|
|
|
* @param string|null $name Name of the user which should receive all replies or null for no name |
100
|
|
|
* @return \Aimeos\MW\Mail\Message\Iface Message object |
101
|
|
|
*/ |
102
|
|
|
public function addReplyTo( $email, $name = null ) |
103
|
|
|
{ |
104
|
|
|
$this->object->setReplyTo( $email, $name ); |
105
|
|
|
return $this; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Adds a custom header to the message. |
111
|
|
|
* |
112
|
|
|
* @param string $name Name of the custom e-mail header |
113
|
|
|
* @param string $value Text content of the custom e-mail header |
114
|
|
|
* @return \Aimeos\MW\Mail\Message\Iface Message object |
115
|
|
|
*/ |
116
|
|
|
public function addHeader( $name, $value ) |
117
|
|
|
{ |
118
|
|
|
$this->object->addHeader( $name, $value ); |
119
|
|
|
return $this; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Sets the e-mail address and name of the sender of the message (higher precedence than "From"). |
125
|
|
|
* |
126
|
|
|
* @param string $email Source e-mail address |
127
|
|
|
* @param string|null $name Name of the user who sent the message or null for no name |
128
|
|
|
* @return \Aimeos\MW\Mail\Message\Iface Message object |
129
|
|
|
*/ |
130
|
|
|
public function setSender( $email, $name = null ) |
131
|
|
|
{ |
132
|
|
|
$this->object->setFrom( $email, $name ); |
133
|
|
|
return $this; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Sets the subject of the message. |
139
|
|
|
* |
140
|
|
|
* @param string $subject Subject of the message |
141
|
|
|
* @return \Aimeos\MW\Mail\Message\Iface Message object |
142
|
|
|
*/ |
143
|
|
|
public function setSubject( $subject ) |
144
|
|
|
{ |
145
|
|
|
$this->object->setSubject( $subject ); |
146
|
|
|
return $this; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Sets the text body of the message. |
152
|
|
|
* |
153
|
|
|
* @param string $message Text body of the message |
154
|
|
|
* @return \Aimeos\MW\Mail\Message\Iface Message object |
155
|
|
|
*/ |
156
|
|
|
public function setBody( $message ) |
157
|
|
|
{ |
158
|
|
|
$this->object->setBodyText( $message ); |
159
|
|
|
return $this; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* Sets the HTML body of the message. |
165
|
|
|
* |
166
|
|
|
* @param string $message HTML body of the message |
167
|
|
|
* @return \Aimeos\MW\Mail\Message\Iface Message object |
168
|
|
|
*/ |
169
|
|
|
public function setBodyHtml( $message ) |
170
|
|
|
{ |
171
|
|
|
$this->html = $message; |
172
|
|
|
return $this; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* Adds an attachment to the message. |
178
|
|
|
* |
179
|
|
|
* @param string $data Binary or string |
180
|
|
|
* @param string $mimetype Mime type of the attachment (e.g. "text/plain", "application/octet-stream", etc.) |
181
|
|
|
* @param string|null $filename Name of the attached file (or null if inline disposition is used) |
182
|
|
|
* @param string $disposition Type of the disposition ("attachment" or "inline") |
183
|
|
|
* @return \Aimeos\MW\Mail\Message\Iface Message object |
184
|
|
|
*/ |
185
|
|
|
public function addAttachment( $data, $mimetype, $filename, $disposition = 'attachment' ) |
186
|
|
|
{ |
187
|
|
|
$enc = \Zend_Mime::ENCODING_BASE64; |
|
|
|
|
188
|
|
|
$this->object->createAttachment( $data, $mimetype, $disposition, $enc, $filename ); |
189
|
|
|
|
190
|
|
|
return $this; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* Embeds an attachment into the message and returns its reference. |
196
|
|
|
* |
197
|
|
|
* @param string $data Binary or string |
198
|
|
|
* @param string $mimetype Mime type of the attachment (e.g. "text/plain", "application/octet-stream", etc.) |
199
|
|
|
* @param string|null $filename Name of the attached file |
200
|
|
|
* @return string Content ID for referencing the attachment in the HTML body |
201
|
|
|
*/ |
202
|
|
|
public function embedAttachment( $data, $mimetype, $filename ) |
203
|
|
|
{ |
204
|
|
|
$cnt = 0; |
205
|
|
|
$newfile = $filename; |
206
|
|
|
|
207
|
|
|
while( isset( $this->embedded[$newfile] ) ) { |
208
|
|
|
$newfile = ++$cnt . '_' . $filename; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
$part = new \Zend_Mime_Part( $data ); |
|
|
|
|
212
|
|
|
|
213
|
|
|
$part->disposition = \Zend_Mime::DISPOSITION_INLINE; |
214
|
|
|
$part->encoding = \Zend_Mime::ENCODING_BASE64; |
215
|
|
|
$part->filename = $newfile; |
216
|
|
|
$part->type = $mimetype; |
217
|
|
|
$part->id = md5( $newfile . mt_rand() ); |
218
|
|
|
|
219
|
|
|
$this->embedded[$newfile] = $part; |
220
|
|
|
|
221
|
|
|
return 'cid:' . $part->id; |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* Returns the internal Zend mail object. |
227
|
|
|
* |
228
|
|
|
* @return \Zend_Mail Zend mail object |
229
|
|
|
*/ |
230
|
|
|
public function getObject() |
231
|
|
|
{ |
232
|
|
|
if( !empty( $this->embedded ) ) |
233
|
|
|
{ |
234
|
|
|
$parts = []; |
235
|
|
|
|
236
|
|
|
if( $this->html != null ) |
237
|
|
|
{ |
238
|
|
|
$part = new \Zend_Mime_Part( $this->html ); |
239
|
|
|
|
240
|
|
|
$part->charset = $this->object->getCharset(); |
241
|
|
|
$part->encoding = \Zend_Mime::ENCODING_QUOTEDPRINTABLE; |
242
|
|
|
$part->disposition = \Zend_Mime::DISPOSITION_INLINE; |
243
|
|
|
$part->type = \Zend_Mime::TYPE_HTML; |
244
|
|
|
|
245
|
|
|
$parts = array( $part ); |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
$msg = new \Zend_Mime_Message(); |
|
|
|
|
249
|
|
|
$msg->setParts( array_merge( $parts, $this->embedded ) ); |
250
|
|
|
|
251
|
|
|
// create html body (text and maybe embedded), modified afterwards to set it to multipart/related |
252
|
|
|
$this->object->setBodyHtml( $msg->generateMessage() ); |
253
|
|
|
|
254
|
|
|
$related = $this->object->getBodyHtml(); |
255
|
|
|
$related->type = \Zend_Mime::MULTIPART_RELATED; |
256
|
|
|
$related->encoding = \Zend_Mime::ENCODING_8BIT; |
257
|
|
|
$related->boundary = $msg->getMime()->boundary(); |
258
|
|
|
$related->disposition = null; |
259
|
|
|
$related->charset = null; |
260
|
|
|
} |
261
|
|
|
else if( $this->html != null ) |
262
|
|
|
{ |
263
|
|
|
$this->object->setBodyHtml( $this->html ); |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
return $this->object; |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
|
270
|
|
|
/** |
271
|
|
|
* Clones the internal objects. |
272
|
|
|
*/ |
273
|
|
|
public function __clone() |
274
|
|
|
{ |
275
|
|
|
$this->object = clone $this->object; |
276
|
|
|
} |
277
|
|
|
} |
278
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths