File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -784,7 +784,7 @@ public function send($content = null) {
784
784
$ this ->_message = $ message ;
785
785
786
786
if (!empty ($ this ->_attachments )) {
787
- // $this->_attachFiles();
787
+ $ this ->_attachFiles ();
788
788
}
789
789
790
790
if (!is_null ($ this ->_boundary )) {
@@ -954,6 +954,28 @@ function _createboundary() {
954
954
$ this ->_boundary = md5 (uniqid (time ()));
955
955
}
956
956
957
+ /**
958
+ * Attach files by adding file contents inside boundaries.
959
+ *
960
+ * @return void
961
+ */
962
+ function _attachFiles () {
963
+ foreach ($ this ->_attachments as $ filename => $ file ) {
964
+ $ handle = fopen ($ file , 'rb ' );
965
+ $ data = fread ($ handle , filesize ($ file ));
966
+ $ data = chunk_split (base64_encode ($ data )) ;
967
+ fclose ($ handle );
968
+
969
+ $ this ->_message [] = '-- ' . $ this ->_boundary ;
970
+ $ this ->_message [] = 'Content-Type: application/octet-stream ' ;
971
+ $ this ->_message [] = 'Content-Transfer-Encoding: base64 ' ;
972
+ $ this ->_message [] = 'Content-Disposition: attachment; filename=" ' . $ filename . '" ' ;
973
+ $ this ->_message [] = '' ;
974
+ $ this ->_message [] = $ data ;
975
+ $ this ->_message [] = '' ;
976
+ }
977
+ }
978
+
957
979
/**
958
980
* Format the message by seeing if it has attachments.
959
981
*
You can’t perform that action at this time.
0 commit comments