-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnomad_mimemail.inc.php
1261 lines (1144 loc) · 34.3 KB
/
nomad_mimemail.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Nomad MIME Mail Copyright (C) 2003-2008 Alejandro Garcia Gonzalez
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of the
* License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* Nomad MIME Mail (formerly known as Nexus MIME Mail)
*
* a class for handling and sending mail MIME type, with support for
* the dispatch by SMTP and SMTP Auth.
*
* * Plain Text
* * HTML
* * Plain Text with Attachments
* * HTML with Attachments
* * HTML with Embedded Images
* * HTML with Embedded Images and Attachments
* * Send email messages via SMTP and Auth SMTP
*
* @author Alejandro Garcia Gonzalez <nexus at developarts dot com>
* @package nomad_mimemail
* @version 1.6.2
* @link http://www.developarts.com/nomad_mimemail
* @link http://www.phpclasses.org/browse/package/1267.html
* @copyright Copyright (c) 2008, Alejandro Garcia Gonzalez
* @license http://www.opensource.org/licenses/lgpl-license.html GNU Lesser General Public License (LGPL)
*/
class nomad_mimemail
{
/**
* Debug Status set how show the errors. "yes" by default.
* If "yes" show a line with error and continue
* If "no" Don't show anything and continue
* If "halt" show a line whit error and stop script
* @see _debug()
* @var string yes|no|halt
* @access private
*/
var $debug_status = "yes";
/**
* The charser of MIME construction. "ISO-8859-1" by default
* @see function set_charset()
* @var string
* @access private
*/
var $charset = "ISO-8859-1";
/**
* Subject text. "No subject" by default
* @see function set_subject()
* @var string
* @access private
*/
var $mail_subject = "No subject";
/**
* Email sender. "Anonymous <[email protected]>" by default
* @see function set_from()
* @var string
* @access private
*/
var $mail_from = "Anonymous <[email protected]>";
/**
* Collection of recipients email address separated by comma
* @see function set_to()
* @see function add_to()
* @var string
* @todo must be an array
* @access private
*/
var $mail_to;
/**
* Collection of carbon copy recipients email address separated by comma
* @see function set_cc()
* @see function add_cc()
* @var string
* @todo must be an array
* @access private
*/
var $mail_cc;
/**
* Collection of bind carbon copy recipients email address separated by comma
* @see function set_bcc()
* @see function add_bcc()
* @var string
* @todo must be an array
* @access private
*/
var $mail_bcc;
/**
* The plain text message of email
* @see function set_text()
* @var string
* @access private
*/
var $mail_text;
/**
* The HTML message of email
* @see function set_html()
* @var string
* @access private
*/
var $mail_html;
/**
* Numeric identifier based in elements of email
* @see _parse_elements()
* @var int
* @access private
*/
var $mail_type;
/**
* Header construction of email
* @see function _build_header
* @var string
* @access private
*/
var $mail_header;
/**
* Body construction of email
* @see function _build_body
* @var string
* @access private
*/
var $mail_body;
/**
* The reply email address
* @see function set_reply_to
* @var string
* @access private
*/
var $mail_reply_to;
/**
* The devilvery error return email address
* @see function set_return_path
* @var string
* @access private
*/
var $mail_return_path;
/**
* Attachments Index
* @see function add_attachment()
* @var int
* @access private
*/
var $attachments_index;
/**
* Mixed Attachments data
* @see function add_attachment()
* @var array
* @access private
*/
var $attachments = array();
/**
* Mixed Attachments images data
* @see function add_attachment()
* @var array
* @access private
*/
var $attachments_img = array();
/**
* Boundary Mixed Hash
* @see function nomad_mimemail()
* @var string
* @access private
*/
var $boundary_mix;
/**
* Boundary Related Hash
* @see function nomad_mimemail()
* @var string
* @access private
*/
var $boundary_rel;
/**
* Boundary Alternative Hash
* @see function nomad_mimemail()
* @var string
* @access private
*/
var $boundary_alt;
/**
* Mark if mail has been sent
* @see function send()
* @var init
* @access private
*/
var $sended_index;
/**
* SMTP connection pointer
* @see function _open_smtp_conn()
* @var resource
* @access private
*/
var $smtp_conn;
/**
* SMTP host name or IP
* @see function set_smtp_host()
* @var string
* @access private
*/
var $smtp_host;
/**
* SMTP host access port
* @see function set_smtp_host()
* @var int
* @access private
*/
var $smtp_port;
/**
* SMTP Username
* @see function set_smtp_auth()
* @var string
* @access private
*/
var $smtp_user;
/**
* SMTP Password
* @see function set_smtp_auth()
* @var string
* @access private
*/
var $smtp_pass;
/**
* SMTP log
* @see function set_smtp_log()
* @var bool
* @access private
*/
var $smtp_log = false;
/**
* SMTP log messages text
* @see function get_smtp_log()
* @var string
* @access private
*/
var $smtp_msg;
/**
* Error string array
* @see function _debug()
* @var array
* @access private
*/
var $error_msg = array(
1 => 'Mail was not sent',
2 => 'Body Build Incomplete',
3 => 'Need a mail recipient in mail_to',
4 => 'No valid Email Address: ',
5 => 'Could not Open File',
6 => 'Could not connect to SMTP server.',
7 => 'Unespected SMTP answer: '
);
/**
* Support MIME types
* @see _get_mimetype()
* @var array
* @access private
*/
var $mime_types = array(
'gif' => 'image/gif',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpe' => 'image/jpeg',
'bmp' => 'image/bmp',
'png' => 'image/png',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'swf' => 'application/x-shockwave-flash',
'doc' => 'application/msword',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
'pdf' => 'application/pdf',
'ps' => 'application/postscript',
'eps' => 'application/postscript',
'rtf' => 'application/rtf',
'bz2' => 'application/x-bzip2',
'gz' => 'application/x-gzip',
'tgz' => 'application/x-gzip',
'tar' => 'application/x-tar',
'zip' => 'application/zip',
'html' => 'text/html',
'htm' => 'text/html',
'txt' => 'text/plain',
'css' => 'text/css',
'js' => 'text/javascript'
);
/**
* Constructor
* void nomad_mimemail()
*/
function nomad_mimemail()
{
$this->boundary_mix = "=-nxs_mix_" . md5(uniqid(rand()));
$this->boundary_rel = "=-nxs_rel_" . md5(uniqid(rand()));
$this->boundary_alt = "=-nxs_alt_" . md5(uniqid(rand()));
$this->attachments_index = 0;
$this->sended_index = 0;
// Line Break BR
if(!defined('BR')){
define('BR', "\r\n", TRUE);
}
}
/**
* void set_from(string mail_from, [string name])
* Set the "from" email address. "Anonymous <[email protected]>" by default
* @access public
* @param string mail_from The email from address
* @param string name Optional name contact
* @return void
*/
function set_from($mail_from, $name = "")
{
if ($this->_validate_mail($mail_from)){
$this->mail_from = !empty($name) ? "$name <$mail_from>" : $mail_from;
}
else {
}
}
/**
* bool set_to(string mail_to, [string name])
* Set the recipient email address
* @access public
* @param string mail_to The recipient email address
* @param string name Optional name contact
* @return bool
*/
function set_to($mail_to, $name = "")
{
if ($this->_validate_mail($mail_to)){
$this->mail_to = !empty($name) ? "$name <$mail_to>" : $mail_to;
return true;
}
return false;
}
/**
* bool set_cc(string mail_cc, [string name])
* Set the carbon copy recipient email address
* @access public
* @param string mail_cc The carbon copy recipient email address
* @param string name Optional name contact
* @return bool
*/
function set_cc($mail_cc, $name = "")
{
if ($this->_validate_mail($mail_cc)){
$this->mail_cc = !empty($name) ? "$name <$mail_cc>" : $mail_cc;
return true;
}
return false;
}
/**
* bool set_bcc(string mail_bcc, [string name])
* Set the blind carbon copy recipient email address
* @access public
* @param string mail_bcc The blind carbon copy recipient email address
* @param string name Optional name contact
* @return bool
*/
function set_bcc($mail_bcc, $name = "")
{
if ($this->_validate_mail($mail_bcc)){
$this->mail_bcc = !empty($name) ? "$name <$mail_bcc>" : $mail_bcc;
return true;
}
return false;
}
/**
* bool set_reply_to(string mail_reply_to, [string name])
* Set the reply email address. If this var is not set, the reply mail are the "from" email address
* @access public
* @param string mail_reply_to The reply email address
* @param string name Optional name contact
* @return bool
*/
function set_reply_to($mail_reply_to, $name = "")
{
if ($this->_validate_mail($mail_reply_to)){
$this->mail_reply_to = !empty($name) ? "$name <$mail_reply_to>" : $mail_reply_to;
return true;
}
return false;
}
/**
* bool add_to(string mail_to, [string name])
* Set or add a new recipient email address
* @access public
* @param string mail_to The recipient email address
* @param string name Optional name contact
* @return bool
*/
function add_to($mail_to, $name = "")
{
if ($this->_validate_mail($mail_to)){
$mail_to = !empty($name) ? "$name <$mail_to>" : $mail_to;
$this->mail_to = !empty($this->mail_to) ? $this->mail_to . ", " . $mail_to : $mail_to;
return true;
}
return false;
}
/**
* bool add_cc(string mail_cc, [string name])
* Set or add a new carbon copy recipient email address
* @access public
* @param string mail_cc The carbon copy recipient email address
* @param string name Optional name contact
* @return bool
*/
function add_cc($mail_cc, $name = "")
{
if ($this->_validate_mail($mail_cc)){
$mail_cc = !empty($name) ? "$name <$mail_cc>" : $mail_cc;
$this->mail_cc = !empty($this->mail_cc) ? $this->mail_cc . ", " . $mail_cc : $mail_cc;
return true;
}
return false;
}
/**
* bool add_bcc(string mail_bcc, [string name])
* Set or add a new blind carbon copy recipient email address
* @access public
* @param string mail_bcc The blind carbon copy recipient email address
* @param string name Optional name contact
* @return bool
*/
function add_bcc($mail_bcc, $name = "")
{
if ($this->_validate_mail($mail_bcc)){
$mail_bcc = !empty($name) ? "$name <$mail_bcc>" : $mail_bcc;
$this->mail_bcc = !empty($this->mail_bcc) ? $this->mail_bcc . ", " . $mail_bcc : $mail_bcc;
return true;
}
return false;
}
/**
* bool add_reply_to(string mail_reply_to, [string name])
* Set or add a new reply email address. If this var is not set, the reply mail are the "from" email address
* @access public
* @param string mail_reply_to The reply email address
* @param string name Optional name contact
* @return bool
*/
function add_reply_to($mail_reply_to, $name = "")
{
if ($this->_validate_mail($mail_reply_to)){
$mail_reply_to = !empty($name) ? "$name <$mail_reply_to>" : $mail_reply_to;
$this->mail_reply_to = !empty($this->mail_reply_to) ? $this->mail_reply_to . ", " . $mail_reply_to : $mail_reply_to;
return true;
}
return false;
}
/**
* bool set_return_path(string mail_return_path)
* Set the devilvery error return email address
* @access public
* @param string mail_return_path The delivery error email account
* @return bool
*/
function set_return_path($mail_return_path)
{
if ($this->_validate_mail($mail_return_path)){
$this->mail_return_path = $mail_return_path;
return true;
}
return false;
}
/**
* void set_subject(string subject)
* Set the email subject string. "No subject" by default
* @access public
* @param string subject
* @return void
*/
function set_subject($subject)
{
$this->mail_subject = !empty($subject) ? trim($subject) : "No subject";
}
/**
* void set_text(string text)
* Set the plain text message in body of email
* @access public
* @param string text The plain text message
* @return void
*/
function set_text($text)
{
if (!empty($text)){
$this->mail_text = preg_replace("(\r\n|\r|\n)", BR, $text);
}
}
/**
* void set_html(string html)
* Set the HTML message in body of email
* @access public
* @param string html The HTML message
* @return void
*/
function set_html($html)
{
if (!empty($html)){
$this->mail_html = preg_replace("(\r\n|\r|\n)", BR, $html);
}
}
/**
* void set_charset(string charset)
* Set the charset if email
* @access public
* @param string charset The CharSet
* @return void
*/
function set_charset($charset)
{
if (!empty($charset)){
$this->charset = $charset;
}
}
/**
* bool set_smtp_host(string host, [int port])
* Set the SMTP host and port, if you call this method with valid parameters, the class sends email through SMTP
* @access public
* @param string host The Hostname/IP of the SMTP server
* @param int port Optional, the port to connect to SMTP server
* @return bool
*/
function set_smtp_host($host, $port = 25)
{
if (!empty($host) && is_numeric($port)){
$this->smtp_host = $host;
$this->smtp_port = $port;
return true;
}
return false;
}
/**
* bool set_smtp_host(string host, [int port])
* Set the Auth SMTP user and password, you need to call method set_smtp_host before
* @access public
* @param string user The Username Authentication account
* @param string pass The Password Authentication account
* @return bool
*/
function set_smtp_auth($user, $pass)
{
if(!empty($user) && !empty($pass)){
$this->smtp_user = $user;
$this->smtp_pass = $pass;
return true;
}
return false;
}
/**
* string get_eml()
* Get the EML format message of the email
* @access public
* @return mixed string if message has build, false if not
*/
function get_eml()
{
if ($this->_build_body()){
return
$this->mail_header . BR .
'Subject: ' . $this->mail_subject . BR .
$this->mail_body;
}
return false;
}
/**
* bool add_attachment(mixed file, string name, [string type])
* Add a file attachment
* @access public
* @param string file
* @param string name
* @param string type
* @return bool
*/
function add_attachment($file, $name, $type = "")
{
if (($content = $this->_open_file($file))){
$this->attachments[$this->attachments_index] = array(
'content' => chunk_split(base64_encode($content), 76, BR),
'name' => $name,
'type' => (empty($type) ? $this->_get_mimetype($name): $type),
'embedded' => false
);
$this->attachments_index++;
}
}
/**
* bool add_content_attachment(mixed file, string name, [string type])
* Add a content to an attachment
* @access public
* @param string content
* @param string name
* @param string type
* @return bool
*/
function add_content_attachment($content, $name, $type = "")
{
$this->attachments[$this->attachments_index] = array(
'content' => chunk_split(base64_encode($content), 76, BR),
'name' => $name,
'type' => (empty($type) ? $this->_get_mimetype($name): $type),
'embedded' => false
);
$this->attachments_index++;
}
/**
* void new_mail([mixed from], [mixed to], [string subject], [string text], [string html])
* Method shortcut to create an email
* @access public
* @return void
*/
function new_mail($from = "", $to = "", $subject = "", $text = "", $html = "")
{
// First, clear all vars
$this->mail_subject = "";
$this->mail_from = "";
$this->mail_to = "";
$this->mail_cc = "";
$this->mail_bcc = "";
$this->mail_text = "";
$this->mail_html = "";
$this->mail_header = "";
$this->mail_body = "";
$this->mail_reply_to = "";
$this->mail_return_path = "";
$this->attachments_index = 0;
$this->sended_index = 0;
// Clear Array Vars
$this->attachments = array();
$this->attachments_img = array();
// Asign vars
if (is_array($from)){
$this->set_from($from[0],$from[1]);
$this->set_return_path($from[0]);
}
else {
$this->set_from($from);
$this->set_return_path($from);
}
if (is_array($to)){
$this->set_to($to[0],$to[1]);
}
else {
$this->set_to($to);
}
$this->set_subject($subject);
$this->set_text($text);
$this->set_html($html);
}
/**
* bool send()
* Send the email message
* @access public
* @return bool
*/
function send()
{
if ($this->sended_index == 0 && !$this->_build_body()){
$this->_debug(1);
return false;
}
if (empty($this->smtp_host) && !empty($this->mail_return_path) && $this->_php_version_check('4.0.5') && !($this->_php_version_check('4.2.3') && ini_get('safe_mode'))){
return mail($this->mail_to, $this->mail_subject, $this->mail_body, $this->mail_header, '-f'.$this->mail_return_path);
}
elseif (empty($this->smtp_host)) {
return mail($this->mail_to, $this->mail_subject, $this->mail_body, $this->mail_header);
}
elseif (!empty($this->smtp_host)){
return $this->_smtp_send();
}
else {
return false;
}
}
/**
* void _build_header()
* Build all the headers of email
* @access private
* @param text content_type The Content Type of email
* @return void
*/
function _build_header($content_type)
{
$this->mail_header = "";
if (!empty($this->smtp_host)){
$this->mail_header .= "Subject: " . $this->mail_subject . BR;
}
if (!empty($this->mail_from)){
$this->mail_header .= "From: " . $this->mail_from . BR;
$this->mail_header .= !empty($this->mail_reply_to) ? "Reply-To: " . $this->mail_reply_to . BR : "Reply-To: " . $this->mail_from . BR;
}
if (!empty($this->mail_to) && !empty($this->smtp_host)){ // FixBug: http://www.developarts.com/version_14_de_nomad_mime_mail#comment-294
$this->mail_header .= "To: " . $this->mail_to . BR;
}
if (!empty($this->mail_cc)){
$this->mail_header .= "Cc: " . $this->mail_cc . BR;
}
if (!empty($this->mail_bcc) && empty($this->smtp_host)){
$this->mail_header .= "Bcc: " . $this->mail_bcc . BR;
}
if (!empty($this->mail_return_path)){
$this->mail_header .= "Return-Path: " . $this->mail_return_path . BR;
}
$this->mail_header .= $content_type . BR;
if (!empty($this->smtp_host)){
$this->mail_header .= "Date: " . date("r") . BR;
}
$this->mail_header .= "Message-Id: <" . md5(uniqid(rand())) . ".nomad_mimemail@" . $_SERVER['SERVER_ADDR'] . ">" . BR;
$this->mail_header .= "MIME-Version: 1.0" . BR;
$this->mail_header .= "X-Mailer: Nomad MIME Mail ". $this->get_version() . BR . BR;
}
/**
* bool _build_body()
* Build body email message
* @access private
* @return bool
*/
function _build_body()
{
$bit_mode='7bit';
if ($this->charset=='UTF-8')
{
$bit_mode='quoted-printable';
}
switch ($this->_parse_elements()){
case 1: // Plain Text
$this->_build_header("Content-Type: text/plain; charset=\"$this->charset\"");
$this->mail_body = $this->mail_text;
break;
case 3: // Plain Text + HTML
$this->_build_header("Content-Type: multipart/alternative; boundary=\"$this->boundary_alt\"");
$this->mail_body .= "--" . $this->boundary_alt . BR;
$this->mail_body .= "Content-Type: text/plain; charset=\"$this->charset\"" . BR;
$this->mail_body .= "Content-Transfer-Encoding: $bit_mode" . BR . BR;
$this->mail_body .= $this->mail_text . BR . BR;
$this->mail_body .= "--" . $this->boundary_alt . BR;
$this->mail_body .= "Content-Type: text/html; charset=\"$this->charset\"" . BR;
$this->mail_body .= "Content-Transfer-Encoding: $bit_mode" . BR . BR;
$this->mail_body .= $this->mail_html . BR;
$this->mail_body .= "--" . $this->boundary_alt . "--" . BR;
break;
case 5: // Plain Text + Attachments
$this->_build_header("Content-Type: multipart/mixed; boundary=\"$this->boundary_mix\"");
$this->mail_body .= "--" . $this->boundary_mix . BR;
$this->mail_body .= "Content-Type: text/plain; charset=\"$this->charset\"" . BR;
$this->mail_body .= "Content-Transfer-Encoding: $bit_mode" . BR . BR;
$this->mail_body .= $this->mail_text . BR . BR;
foreach($this->attachments as $value){
$this->mail_body .= "--" . $this->boundary_mix . BR;
$this->mail_body .= "Content-Type: " . $value['type'] . "; name=\"" . $value['name'] . "\"" . BR;
$this->mail_body .= "Content-Disposition: attachment; filename=\"" . $value['name'] . "\"" . BR;
$this->mail_body .= "Content-Transfer-Encoding: base64" . BR . BR;
$this->mail_body .= $value['content'] . BR . BR;
}
$this->mail_body .= "--" . $this->boundary_mix . "--" . BR;
break;
case 7: // Plain Text + HTML + Attachments
$this->_build_header("Content-Type: multipart/mixed; boundary=\"$this->boundary_mix\"");
$this->mail_body .= "--" . $this->boundary_mix . BR;
$this->mail_body .= "Content-Type: multipart/alternative; boundary=\"$this->boundary_alt\"" . BR . BR;
$this->mail_body .= "--" . $this->boundary_alt . BR;
$this->mail_body .= "Content-Type: text/plain; charset=\"$this->charset\"" . BR;
$this->mail_body .= "Content-Transfer-Encoding: 7bit" . BR . BR;
$this->mail_body .= $this->mail_text . BR . BR;
$this->mail_body .= "--" . $this->boundary_alt . BR . BR;
$this->mail_body .= "Content-Type: text/html; charset=\"$this->charset\"" . BR;
$this->mail_body .= "Content-Transfer-Encoding: 7bit" . BR;
$this->mail_body .= $this->mail_html . BR . BR;
$this->mail_body .= "--" . $this->boundary_alt . "--" . BR . BR;
foreach($this->attachments as $value){
$this->mail_body .= "--" . $this->boundary_mix . BR;
$this->mail_body .= "Content-Type: " . $value['type'] . "; name=\"" . $value['name'] . "\"" . BR;
$this->mail_body .= "Content-Disposition: attachment; filename=\"" . $value['name'] . "\"" . BR;
$this->mail_body .= "Content-Transfer-Encoding: base64" . BR . BR;
$this->mail_body .= $value['content'] . BR . BR;
}
$this->mail_body .= "--" . $this->boundary_mix . "--" . BR;
break;
case 11: // Plain Text + HTML + Embedded Images
$this->_build_header("Content-Type: multipart/related; type=\"multipart/alternative\"; boundary=\"$this->boundary_rel\"");
$this->mail_body .= "--" . $this->boundary_rel . BR;
$this->mail_body .= "Content-Type: multipart/alternative; boundary=\"$this->boundary_alt\"" . BR . BR;
$this->mail_body .= "--" . $this->boundary_alt . BR;
$this->mail_body .= "Content-Type: text/plain; charset=\"$this->charset\"" . BR;
$this->mail_body .= "Content-Transfer-Encoding: $bit_mode" . BR . BR;
$this->mail_body .= $this->mail_text . BR . BR;
$this->mail_body .= "--" . $this->boundary_alt . BR;
$this->mail_body .= "Content-Type: text/html; charset=\"$this->charset\"" . BR;
$this->mail_body .= "Content-Transfer-Encoding: $bit_mode" . BR . BR;
$this->mail_body .= $this->mail_html . BR . BR;
$this->mail_body .= "--" . $this->boundary_alt . "--" . BR . BR;
foreach($this->attachments as $value){
if ($value['embedded']){
$this->mail_body .= "--" . $this->boundary_rel . BR;
$this->mail_body .= "Content-ID: <" . $value['embedded'] . ">" . BR;
$this->mail_body .= "Content-Type: " . $value['type'] . "; name=\"" . $value['name'] . "\"" . BR;
$this->mail_body .= "Content-Disposition: attachment; filename=\"" . $value['name'] . "\"" . BR;
$this->mail_body .= "Content-Transfer-Encoding: base64" . BR . BR;
$this->mail_body .= $value['content'] . BR . BR;
}
}
$this->mail_body .= "--" . $this->boundary_rel . "--" . BR;
break;
case 15: // Plain Text + HTML + Embedded Images + Attachments
$this->_build_header("Content-Type: multipart/mixed; boundary=\"$this->boundary_mix\"");
$this->mail_body .= "--" . $this->boundary_mix . BR;
$this->mail_body .= "Content-Type: multipart/related; type=\"multipart/alternative\"; boundary=\"$this->boundary_rel\"" . BR . BR;
$this->mail_body .= "--" . $this->boundary_rel . BR;
$this->mail_body .= "Content-Type: multipart/alternative; boundary=\"$this->boundary_alt\"" . BR . BR;
$this->mail_body .= "--" . $this->boundary_alt . BR;
$this->mail_body .= "Content-Type: text/plain; charset=\"$this->charset\"" . BR;
$this->mail_body .= "Content-Transfer-Encoding: $bit_mode" . BR . BR;
$this->mail_body .= $this->mail_text . BR . BR;
$this->mail_body .= "--" . $this->boundary_alt . BR;
$this->mail_body .= "Content-Type: text/html; charset=\"$this->charset\"" . BR;
$this->mail_body .= "Content-Transfer-Encoding: $bit_mode" . BR . BR;
$this->mail_body .= $this->mail_html . BR . BR;
$this->mail_body .= "--" . $this->boundary_alt . "--" . BR . BR;
foreach($this->attachments as $value){
if ($value['embedded']){
$this->mail_body .= "--" . $this->boundary_rel . BR;
$this->mail_body .= "Content-ID: <" . $value['embedded'] . ">" . BR;
$this->mail_body .= "Content-Type: " . $value['type'] . "; name=\"" . $value['name'] . "\"" . BR;
$this->mail_body .= "Content-Disposition: attachment; filename=\"" . $value['name'] . "\"" . BR;
$this->mail_body .= "Content-Transfer-Encoding: base64" . BR . BR;
$this->mail_body .= $value['content'] . BR . BR;
}
}
$this->mail_body .= "--" . $this->boundary_rel . "--" . BR . BR;
foreach($this->attachments as $value){
if (!$value['embedded']){
$this->mail_body .= "--" . $this->boundary_mix . BR;
$this->mail_body .= "Content-Type: " . $value['type'] . "; name=\"" . $value['name'] . "\"" . BR;
$this->mail_body .= "Content-Disposition: attachment; filename=\"" . $value['name'] . "\"" . BR;
$this->mail_body .= "Content-Transfer-Encoding: base64" . BR . BR;
$this->mail_body .= $value['content'] . BR . BR;
}
}
$this->mail_body .= "--" . $this->boundary_mix . "--" . BR;
break;
default:
return $this->_debug(2);
}
$this->sended_index++;
return true;
}
/**
* bool _php_version_check(string vercheck)
* Check if current version of PHP is above than other
* @access private
* @param string vercheck The compare version of PHP
* @return bool
*/
function _php_version_check($vercheck)
{
if (version_compare(PHP_VERSION, $vercheck) === 1){
return true;
}
return false;
}
/**
* mixed _parse_elements()
* Check all email message elements and return a identifier
* @access private
* @return mixed int|false
*/
function _parse_elements()
{
if (empty($this->mail_to)){
return $this->_debug(3);
}
$this->_search_images();
$this->mail_type = 0; // None
if (!empty($this->mail_text)){
$this->mail_type = $this->mail_type + 1; // Plain Text
}
if (!empty($this->mail_html)){
$this->mail_type = $this->mail_type + 2; // HTML
if (empty($this->mail_text)){
$this->mail_text = strip_tags(eregi_replace("<br>", BR, $this->mail_html));
$this->mail_type = $this->mail_type + 1; // Plain Text
}
}
if ($this->attachments_index != 0){
if (count($this->attachments_img) != 0){
$this->mail_type = $this->mail_type + 8; // Embedded Images
}
if ((count($this->attachments) - count($this->attachments_img)) >= 1){
$this->mail_type = $this->mail_type + 4; // Attachments
}
}
return $this->mail_type;
}
/**
* void _search_images()
* Search all embeded images in HTML and attachments
* @access private
* @return void
*/