@@ -66,11 +66,6 @@ class MailMessage extends DataObject
6666 */
6767 protected $ files = [];
6868
69- /**
70- * @var array
71- */
72- protected $ fileLinks = [];
73-
7469 /**
7570 * Message constructor.
7671 *
@@ -166,7 +161,7 @@ public function getBody()
166161 if (!empty ($ this ->body )) {
167162 return $ this ->body ;
168163 } elseif (!empty ($ this ->bodyTemplate )) {
169- return render_template ($ this ->bodyTemplate , $ this ->tokens , $ this -> fileLinks );
164+ return render_template ($ this ->bodyTemplate , $ this ->tokens );
170165 } else {
171166 return null ;
172167 }
@@ -180,32 +175,17 @@ public function getAltBody()
180175 if (!empty ($ this ->altBody )) {
181176 return $ this ->altBody ;
182177 } else {
183- return render_template ($ this ->altBodyTemplate , $ this ->tokens , $ this -> fileLinks );
178+ return render_template ($ this ->altBodyTemplate , $ this ->tokens );
184179 }
185180 }
186181
187182 public function setFiles ()
188183 {
189- $ uploadFolder = $ this ->getFullPathOfUploadFolder ();
190-
191- if (!file_exists ($ uploadFolder )) {
192- mkdir ($ uploadFolder , 0777 , true );
193- }
194-
195184 foreach ($ this ->attachments as $ file )
196185 {
197186 /** @var File $file */
198- $ path = $ this ->getFullPathOfUploadFolder () . DIRECTORY_SEPARATOR . $ file ->uniqName ;
199- @chmod ($ path , 0666 & ~umask ());
200-
201- if (move_uploaded_file ($ file ->tmp_name , $ path )) {
202-
203- if ($ file ->size > self ::ATTACHMENTS_SIZE_LIMIT ) {
204- $ domainPath = $ _SERVER ['HTTP_ORIGIN ' ] . $ this ->getWebUploadFolder () .DIRECTORY_SEPARATOR . $ file ->uniqName ;
205- $ this ->addFileLink ([$ domainPath => $ file ->name ]);
206- } else {
207- $ this ->addFile ([$ path => $ file ->name ]);
208- }
187+ if (!$ file ->size > self ::ATTACHMENTS_SIZE_LIMIT ) {
188+ $ this ->addFile ([$ file ->uploadPath => $ file ->name ]);
209189 }
210190 }
211191
@@ -228,43 +208,4 @@ protected function addFile($data)
228208 $ this ->files [] = new EmailAttachment ($ data );
229209 }
230210
231- /**
232- * @param $data
233- */
234- protected function addFileLink ($ data )
235- {
236- $ this ->fileLinks [] = new EmailAttachment ($ data );
237- }
238-
239- /**
240- * @return array
241- */
242- public function getFileLinks ()
243- {
244- return $ this ->fileLinks ;
245- }
246-
247- /**
248- * @return string
249- */
250- protected function getFullPathOfUploadFolder ()
251- {
252- return __DIR__ . $ this ->getUploadFolder ();
253- }
254-
255- /**
256- * @return string
257- */
258- protected function getUploadFolder ()
259- {
260- return '/../../examples ' . $ this ->getWebUploadFolder ();
261- }
262-
263- /**
264- * @return string
265- */
266- protected function getWebUploadFolder ()
267- {
268- return '/attachments ' ;
269- }
270211}
0 commit comments