PageRenderTime 97ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/controllers/components/qdmail.php

http://github.com/slywalker/account_manager
PHP | 4121 lines | 3564 code | 216 blank | 341 comment | 530 complexity | c33ac2b2c158532df01d2aa103a6cf7b MD5 | raw file
Possible License(s): MIT

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * Qdmail ver 1.2.6b
  4. * E-Mail for multibyte charset
  5. *
  6. * PHP versions 4 and 5 (PHP4.3 upper)
  7. *
  8. * Copyright 2008, Spok in japan , tokyo
  9. * hal456.net/qdmail : http://hal456.net/qdmail/
  10. * & CPA-LAB/Technical : http://www.cpa-lab.com/tech/
  11. * Licensed under The MIT License License
  12. *
  13. * @copyright Copyright 2008, Spok.
  14. * @link http://hal456.net/qdmail/
  15. * @version 1.2.6b
  16. * @lastmodified 2008-10-23
  17. * @license http://www.opensource.org/licenses/mit-license.php The MIT License
  18. *
  19. * Qdmail is sending e-mail library for multibyte language ,
  20. * easy , quickly , usefull , and you can specify deeply the details.
  21. * Copyright (C) 2008 spok
  22. */
  23. //-------------------------------------------
  24. // For CakePHP , extended 'Object' Class ,
  25. // if including in CakePHP Component .
  26. // At normal PHP Script or another Framework ,
  27. // 'QdmailBranch' means Dummy Base Class .
  28. //-------------------------------------------
  29. if (!defined('QD_DS')) {
  30. define('QD_DS', DIRECTORY_SEPARATOR);
  31. }
  32. if ( defined('CAKE_CORE_INCLUDE_PATH') || defined('CAKE')) {
  33. class QdmailBranch extends Object{
  34. }
  35. }else{
  36. class QdmailBranch{
  37. }
  38. }
  39. if( !function_exists( 'qd_send_mail' ) ){
  40. function qd_send_mail( $type , $to = null, $subject = null , $content = null , $other_header = array() , $attach = null, $debug = 0 ){
  41. $type_org = $type;
  42. $mail = & Qdmail::getInstance();
  43. $mail->debug = $debug;
  44. if(!is_array($type)){
  45. $type = array('TYPE'=>$type);
  46. }
  47. list( $type , $link ) = $mail->keyUpper($type);
  48. $option = array();
  49. $return = array();
  50. $type = array_change_key_case( $type , CASE_UPPER ) ;
  51. $option = (isset($type['OPTION']) && is_array($type['OPTION'])) ? $type['OPTION'] : array(); $return = (isset($type['RETURN']) && is_array($type['RETURN'])) ? $type['RETURN'] : array();
  52. if(isset($type['SMTP'])){
  53. $option = array_merge($option,array('SMTP'=>true,'smtpServer'=>$type['SMTP']));
  54. }
  55. $type = isset($type['TYPE']) ? $type['TYPE']:'text';
  56. $_type=array('TEXT'=>'Text','HTML'=>'Html','DECO'=>'Deco' ,'DECOTEMPLATE'=>'DecoTemplate');
  57. $easy_method = isset($_type[strtoupper($type)]) ? 'easy'.$_type[strtoupper($type)]:'_';
  58. if(!method_exists($mail,$easy_method)){
  59. $mail -> errorGather('Illegal type \''.$type.'\'',__LINE__);
  60. return false;
  61. }
  62. $ret = $mail->{$easy_method}( $to , $subject , $content , $other_header , $attach , $option );
  63. foreach($return as $method => $value ){
  64. if(method_exists($mail,$method)){
  65. $type_org[$link['RETURN']][$method] = $mail -> {$method}($value);
  66. }
  67. }
  68. if(0!==count($return)){
  69. $type_org[$link['RETURN']]['qd_send_mail'] = $ret;
  70. $ret = $type_org;
  71. }
  72. return $ret;
  73. }
  74. }
  75. class QdmailBase extends QdmailBranch{
  76. //----------------------------
  77. // Default Language
  78. // If you do not Japanese
  79. // Please change this propaty for your Language and Encoding
  80. //----------------------------
  81. var $lang_def = "ja";
  82. var $encoding_def = "utf-8";
  83. var $detect_def = array('ASCII','JIS','UTF-8','EUC-JP','SJIS');
  84. var $mb_parameter_stack = null;
  85. var $united_charset = null;
  86. var $mime_encode_max = 75;
  87. //------------------------
  88. // Time Zone , Message Id
  89. //------------------------
  90. var $time_zone = null; // '+0900' in Japan
  91. var $message_id = true;
  92. var $salt = 'qdmail';
  93. var $message_id_right = null;
  94. //----------------------------
  95. // Line Feed Character & kana
  96. //----------------------------
  97. var $LFC = "\r\n";// Notice: CRLF ,If you failed, change to "\n"
  98. var $LFC_Qmail = null;
  99. //var $is_qmail = null;
  100. var $is_qmail = false;
  101. var $language = 'ja';
  102. var $kana = false; // kana header
  103. //----------
  104. // sysytem
  105. //----------
  106. var $kana_content_relation = false;
  107. var $name = 'Qdmail';
  108. var $version = '1.2.6b';
  109. var $xmailer = 'PHP-Qdmail';
  110. var $license = 'The_MIT_License';
  111. //--------------------
  112. // charset , encoding
  113. //--------------------
  114. var $charset_header = 'iso-2022-jp';
  115. var $charset_content = 'iso-2022-jp';
  116. var $charset_attach_filename = 'iso-2022-jp';
  117. var $content_transfer_enc_text = '7bit';
  118. var $content_transfer_enc_html = '7bit';
  119. var $detect_order = false;
  120. // var $detect_order = "iso-2022-jp,eucJP-win,UTF-8,SJIS-win,jis,ASCII";
  121. var $qdmail_system_charset = 'utf-8';
  122. var $force_change_charset = false;
  123. var $corres_charset = array(
  124. 'HEADER'=>'charset_header',
  125. 'BODY'=>'charset_content',
  126. 'ATTACH'=>'charset_attach_filename',
  127. 'TEXT'=>'content_transfer_enc_text',
  128. 'HTML'=>'content_transfer_enc_html',
  129. 'DETECT'=>'detect_order',
  130. 'SYSTEM'=>'qdmail_system_charset',
  131. ) ;
  132. //--------------------------
  133. // for address
  134. //--------------------------
  135. var $varidate_address_regex = '/[^@]+@[^@]+/';
  136. var $allow_blank_header = false;
  137. var $addr_many = array(
  138. 'TO' => true,
  139. 'CC' => true,
  140. 'BCC' => true,
  141. 'FROM' => false,
  142. 'REPLYTO'=> false
  143. );
  144. var $addr_head_name = array(
  145. 'TO' => 'To',
  146. 'CC' => 'Cc',
  147. 'BCC' => 'Bcc',
  148. 'FROM' => 'From',
  149. 'REPLYTO'=>'Reply-To'
  150. );
  151. var $header_must =array( 'TO' , 'FROM' , 'SUBJECT' );
  152. var $body_empty_allow = false;
  153. var $tokey = array(
  154. '_ADDR' => 'mail',
  155. '_NAME' => 'name',
  156. );
  157. //--------------
  158. // content_id
  159. //--------------
  160. var $content_id_include_attach_path = false ;
  161. var $content_id_only_filename = true ;
  162. //---------------
  163. // Once mode
  164. //---------------
  165. var $body_structure = array();
  166. var $body_build_once = false;
  167. var $body_already_build = false;
  168. var $attach_build_once = true;
  169. var $attach_already_build = false;
  170. //------------------------------
  171. // simple replace
  172. //------------------------------
  173. var $simple_replace = false;
  174. var $replace = array();
  175. var $replace_with_to_priority= true;
  176. var $replace_def = array();
  177. // simple replace command prefix
  178. var $rep_prefix = null;
  179. //---------
  180. // wordwrap
  181. //---------
  182. var $wordwrap_allow = false;
  183. var $wrap_prohibit_allow = false;
  184. var $wordwrap_length= 45 ;
  185. // inteligent wordwrap
  186. // false is that the word exist in the line ,
  187. // true is that the word must be the beginning of a line
  188. var $wrap_except = array(
  189. 'http://'=>false,
  190. 'code'=>true,
  191. );
  192. var $wrap_prohibit_top=',.;:–?!‼、。.))]}}〕〉》」』】〙〗〟’”»ヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎ‐〜?!';
  193. var $wrap_prohibit_end='(([{{〔〈《「『【〘〖‘“« ';
  194. var $wrap_prohibit = array();
  195. // multibyte wordwrap , by wordcount or by wordwidth
  196. var $wrap_width = true;
  197. // multibyte wordwidth compare by ascii
  198. var $mb_strwidth_magni = 2;
  199. //------------------
  200. // To Separate mode
  201. //------------------
  202. var $to_separate = false ;
  203. //----------------------------
  204. // html mail
  205. //----------------------------
  206. var $is_html = null ;
  207. var $auto_both = true ; // text & html
  208. var $inline_mode = false;
  209. var $deco_kind = null ; // number of $this->deco_def
  210. var $auto_deco_judge= false;
  211. var $no_inline_attach_structure = 0;
  212. var $deco_def_default = 0;
  213. var $deco_def =array(
  214. array(
  215. 'OPTION_NAME' => array( 'MHTML' , 'INLINE' , 'PC' ),
  216. 'STRUCTURE' => 1,
  217. '_CHARSET' => 'iso-2022-jp' ,
  218. 'ENC_TEXT' => '7bit',
  219. 'ENC_HTML' => 'QUOTED-PRINTABLE',
  220. 'HTML_EXTERNAL' => false,
  221. 'DISPOSITION' => true,
  222. ),
  223. array(
  224. 'OPTION_NAME' => array( 'DC' , 'DOCOMO' ),
  225. 'STRUCTURE' => 2,
  226. '_CHARSET' => 'iso-2022-jp',
  227. 'ENC_TEXT' => '7bit',
  228. 'ENC_HTML' => 'QUOTED-PRINTABLE',
  229. 'HTML_EXTERNAL' => array('this','stripCrlf'),
  230. 'DISPOSITION' => false,
  231. ),
  232. array(
  233. 'OPTION_NAME' => array( 'AU' ,'EZ', 'EZWEB'),
  234. 'STRUCTURE' => 3,
  235. '_CHARSET' => 'iso-2022-jp',
  236. 'ENC_TEXT' => '7bit',
  237. 'ENC_HTML' => 'QUOTED-PRINTABLE',
  238. 'HTML_EXTERNAL' => array('this','stripCrlf'),
  239. 'DISPOSITION' => true,
  240. ),
  241. array(
  242. 'OPTION_NAME' => array( 'SB' , 'SOFTBANK' ),
  243. 'STRUCTURE' => 4,
  244. '_CHARSET' => 'iso-2022-jp',
  245. 'ENC_TEXT' => '7bit',
  246. 'ENC_HTML' => 'QUOTED-PRINTABLE',
  247. 'HTML_EXTERNAL' => array('this','stripCrlf') ,
  248. 'DISPOSITION' => true ,
  249. ),
  250. array(
  251. 'OPTION_NAME' => array( 'EM','EMOBILE' ,'EMNET'),
  252. 'STRUCTURE' => 2,
  253. '_CHARSET' => 'iso-2022-jp',
  254. 'ENC_TEXT' => '7bit',
  255. 'ENC_HTML' => 'QUOTED-PRINTABLE',
  256. 'HTML_EXTERNAL' => array('this','stripCrlf') ,
  257. 'DISPOSITION' => true ,
  258. ),
  259. array(
  260. 'OPTION_NAME' => array( 'WL','WILLCOM' ,'POCKET'),
  261. 'STRUCTURE' => 2,
  262. '_CHARSET' => 'iso-2022-jp',
  263. 'ENC_TEXT' => '7bit',
  264. 'ENC_HTML' => 'QUOTED-PRINTABLE',
  265. 'HTML_EXTERNAL' => array('this','stripCrlf') ,
  266. 'DISPOSITION' => true ,
  267. ),
  268. array(
  269. 'OPTION_NAME' => array( 'TEMPLATE_DC' , 'TEMPLATE_DOCOMO' ,'TPL_DC'),
  270. 'STRUCTURE' => 5,
  271. '_CHARSET' => 'Shift_JIS',
  272. 'ENC_TEXT' => '8bit',
  273. 'ENC_HTML' => '8bit',
  274. 'HTML_EXTERNAL' => array('this','stripCrlf'),
  275. 'DISPOSITION' => false,
  276. 'BOUNDARY' => 'mime9DC9bdary',
  277. 'TOP' => array('Decomail-Template'),
  278. 'CID_PREFIX' => 'img_',
  279. 'CID_NUM_COL' => 3,
  280. ),
  281. array(
  282. 'OPTION_NAME' => array( 'TEMPLATE_AU','TPL_AU' ,'TPL_AU_2_0'),
  283. 'STRUCTURE' => 6,
  284. '_CHARSET' => 'iso-2022-jp',
  285. 'ENC_TEXT' => '7bit',
  286. 'ENC_HTML' => '7bit',
  287. 'HTML_EXTERNAL' => array('this','stripCrlf'),
  288. 'DISPOSITION' => false,
  289. 'BOUNDARY' => '--=_KDDI_NEXT_PART_0000',
  290. 'TOP' => array('KDDI_HTML_MAIL_2_0'),
  291. 'CID_PREFIX' => 'img_cid_',
  292. 'CID_NUM_COL' => 3,
  293. ),
  294. array(
  295. 'OPTION_NAME' => array( 'TEMPLATE_AU_1_0','TPL_AU_1_0' ,'TPL_AU_1_0'),
  296. 'STRUCTURE' => 6,
  297. '_CHARSET' => 'iso-2022-jp',
  298. 'ENC_TEXT' => '7bit',
  299. 'ENC_HTML' => '7bit',
  300. 'HTML_EXTERNAL' => array('this','stripCrlf'),
  301. 'DISPOSITION' => false,
  302. 'BOUNDARY' => '--=_KDDI_NEXT_PART_0000',
  303. 'TOP' => array('KDDI_HTML_MAIL_1_0'),
  304. 'CID_PREFIX' => 'img_cid_',
  305. 'CID_NUM_COL' => 3,
  306. ),
  307. array(
  308. 'OPTION_NAME' => array( 'TEMPLATE_SB','TPL_SB' ),
  309. 'STRUCTURE' => 5,
  310. '_CHARSET' => 'Shift_JIS',
  311. 'ENC_TEXT' => '8bit',
  312. 'ENC_HTML' => '8bit',
  313. 'HTML_EXTERNAL' => array('this','stripCrlf'),
  314. 'DISPOSITION' => false,
  315. 'BOUNDARY' => 'aremejkj15a14',
  316. 'TOP' => array('HTMLMail-Template-Version:1.0',
  317. 'HTMLMail-Template-Title:HTMLMail-Template',
  318. ''
  319. ),
  320. 'CID_PREFIX' => '',
  321. 'CID_NUM_COL' => 2,
  322. 'CID_AFTER' => '@areme.jp',
  323. ),
  324. );
  325. var $structure =array(
  326. // no inline attachment
  327. 0 => array(
  328. 'multipart/mixed' => array(
  329. 'multipart/alternative'=>array(
  330. 'html' => 1,
  331. 'plain' => 1,
  332. 'OMIT' => true,
  333. ),
  334. 'image' => 'BOTH', // Available Inline
  335. 'OMIT' => true,
  336. ),
  337. 'OMIT' => true,
  338. ),
  339. // PC inline HTML
  340. 1 => array(
  341. 'multipart/mixed' => array(
  342. 'multipart/alternative'=>array(
  343. 'multipart/related' => array(
  344. 'html' => 1,
  345. 'image' => 'INLINE',
  346. 'OMIT' => true,
  347. ),
  348. 'plain' => 1,
  349. 'OMIT' => true,
  350. ),
  351. 'image' => 'NOT_INLINE', // not inline
  352. 'OMIT' => true,
  353. ),
  354. 'OMIT' => true,
  355. ),
  356. 2 => array(
  357. 'multipart/mixed' => array(
  358. 'multipart/related'=>array(
  359. 'multipart/alternative' => array(
  360. 'plain' => 1,
  361. 'html' => 1,
  362. 'OMIT' => false,
  363. ),
  364. 'image' => 'INLINE',
  365. 'OMIT' => false,
  366. ),
  367. 'OMIT' => false,
  368. 'image' => 'NOT_INLINE',
  369. ),
  370. 'OMIT' => false,
  371. ),
  372. 3 => array(
  373. 'multipart/mixed' => array(
  374. 'multipart/alternative' => array(
  375. 'plain' => 1,
  376. 'html' => 1,
  377. 'OMIT' => false,
  378. ),
  379. 'image' => 'BOTH',
  380. 'OMIT' => false,
  381. ),
  382. 'OMIT' => false,
  383. ),
  384. 4 => array(
  385. 'multipart/related'=>array(
  386. 'multipart/alternative' => array(
  387. 'plain' => 1,
  388. 'html' => 1,
  389. 'OMIT' => false,
  390. ),
  391. 'image' => 'INLINE',
  392. 'OMIT' => false,
  393. ),
  394. 'image' => 'NOT_INLINE',
  395. 'OMIT' => false,
  396. ),
  397. 5 => array(
  398. 'multipart/related'=>array(
  399. 'plain' => 1,
  400. 'html' => 1,
  401. 'image' => 'INLINE',
  402. 'OMIT' => false,
  403. ),
  404. 'OMIT' => false,
  405. ),
  406. 6 => array(
  407. 'multipart/mixed'=>array(
  408. 'plain' => 1,
  409. 'html' => 1,
  410. 'image' => 'INLINE',
  411. 'OMIT' => false,
  412. ),
  413. 'OMIT' => false,
  414. ),
  415. );
  416. var $deco_judge = array(
  417. 'docomo.ne.jp' => 'DC',
  418. 'softbank.ne.jp' => 'SB',
  419. 'i.softbank.ne.jp' => 'SB',
  420. 'disney.ne.jp' => 'SB',
  421. 'vodafone.ne.jp' => 'SB',
  422. 'ezweb.ne.jp' => 'AU',
  423. 'emnet.ne.jp' => 'EM',
  424. 'pdx.ne.jp' => 'WL',
  425. 'gmail.com' => 'DC',
  426. );
  427. //------------------
  428. // using address and content
  429. //------------------
  430. var $to = array() ;
  431. var $from = array() ;
  432. var $cc = array() ;
  433. var $bcc = array() ;
  434. var $done = array() ;
  435. var $undone = array() ;
  436. var $replyto = array() ;
  437. var $recipient = array() ;
  438. var $allways_bcc = null ;
  439. var $header = array() ;
  440. var $other_header = array() ;
  441. var $header_content_type = array();
  442. var $content = array(
  443. 'TEXT'=>array(
  444. 'CONTENT' => null,
  445. 'LENGTH' => null,
  446. '_CHARSET' => null,
  447. 'ENC' => null,
  448. '_ORG_CHARSET' => null,
  449. ),
  450. 'HTML'=>array(
  451. 'CONTENT' => null,
  452. 'ORG_CONTENT' => null,
  453. 'LENGTH' => null,
  454. '_CHARSET' => null,
  455. 'ENC' => null,
  456. '_ORG_CHARSET' => null,
  457. ),
  458. );
  459. var $header_for_mailfunction_to;
  460. var $header_for_mailfunction_subject;
  461. var $header_for_mailfunction_other;
  462. var $content_for_mailfunction;
  463. var $header_for_smtp_array;
  464. var $content_all_for_smtp;
  465. var $header_for_smtp;
  466. //--------------
  467. // attachament
  468. //--------------
  469. var $attach = array();
  470. var $attach_path = null;
  471. var $auto_ext = true ; // mimetypes
  472. var $content_id_fix = false;
  473. //------------------------
  474. // Mailer
  475. //-------------------------
  476. var $mailer = 'mail';
  477. //------------------------
  478. // Sendmail
  479. //-------------------------
  480. var $sendmail = false ;
  481. var $sendmail_path = null;
  482. //------------------------
  483. // SMTP
  484. //-------------------------
  485. var $smtp = false ;
  486. var $smtp_object = null;
  487. var $smtp_loglevel_link = false;
  488. var $smtp_server = array(
  489. 'host' => null ,
  490. 'port' => 25 ,
  491. 'from' => null,
  492. 'user' => null,
  493. 'pass' => null,
  494. 'protocol' => null,
  495. 'pop_host' => null,
  496. 'pop_user' => null,
  497. 'pop_pass' => null,
  498. );
  499. //------------------------
  500. // render Mode
  501. //------------------------
  502. var $render_mode = false;
  503. var $size = array();
  504. //------------------------
  505. // Priority
  506. //------------------------
  507. var $priority = null;
  508. var $priority_def =array(
  509. 'X-Priority' => array( 'HIGH' => 1 , 'NORMAL' => 3 , 'LOW' =>5 ),
  510. 'X-MsMail-Priotiry' => array( 'HIGH'=>'High' , 'NORMAL'=>'Normal' , 'LOW'=>'Low' ),
  511. 'Priotiry' => array( 'HIGH'=>'urgent' , 'NORMAL' => 'normal' , 'LOW'=> 'non-urgent' ),
  512. 'Importance' => array( 'HIGH' =>'High' , 'NORMAL'=>'Normal' ,'LOW' =>'Low' ),
  513. );
  514. //------------------------
  515. // signed
  516. //------------------------
  517. var $sign = false;
  518. var $smime = false;
  519. var $pgp = false;
  520. var $private_key_file = 'private.pem';
  521. var $certificate_file = 'cert.pem';
  522. var $certificate_pass = null;
  523. var $certificate_file_path = null;
  524. var $certificate_temp_path = null;
  525. var $certificate_file_path_win = 'c:\cert';
  526. var $certificate_temp_path_win = 'c:\temp';
  527. var $certificate_file_path_unix = '/user/local/cert';
  528. var $certificate_temp_path_unix = '/tmp';
  529. //------------------------
  530. // etc
  531. //------------------------
  532. var $temporary_path = null;
  533. var $simple_attach = false;
  534. var $keep_parameter = array(false);
  535. var $mta_option = null ;
  536. var $is_create = false;
  537. var $address_validation_method = array('this','validateAddr');
  538. var $boundary_base_degit= 2 ;
  539. var $stack_construct = null ;
  540. var $start_time = null;
  541. var $framework = null;
  542. //-------------------------------
  543. // logs
  544. // 0 is nolog,
  545. // 1 is simple(Message 'Success' & recipt e-mail@address ),
  546. // 2 is including header data,
  547. // 3 is including fulldata,
  548. //------------------------------
  549. var $log_level = 0 ;
  550. var $log_level_max = 3 ;
  551. var $log_path = './';
  552. var $log_filename = 'qdmail.log';
  553. var $log_append = 'a' ;
  554. var $log_dateformat = 'Y-m-d H:i:s';
  555. var $log_LFC = "\n";
  556. // -------------------------------
  557. // error & error logs
  558. // 0 is nolog,
  559. // 1 is simple,
  560. // 2 is including header data,
  561. // 3 is inc fulldata
  562. //--------------------------------
  563. var $error = array();
  564. var $error_stack = array();
  565. var $error_display = true;
  566. var $errorlog_level = 0 ;
  567. var $errorlog_level_max = 3 ;
  568. var $errorlog_path = './';
  569. var $errorlog_filename= 'qbmail_error.log';
  570. var $errorlog_append= 'a' ;
  571. var $ignore_error = false ;
  572. //----------------
  573. // debug
  574. // 0 is no debug mode & really sending ,
  575. // 1 is showing header&body & really sending ,
  576. // 2 is no sending & showing header&body and some vars
  577. //----------------
  578. var $debug = 0 ;
  579. var $debug_report = false;
  580. var $debug_report_path = './';
  581. var $debug_echo_charset= true;
  582. //****************************************************
  583. // Methods
  584. //****************************************************
  585. //--------------------------------
  586. // constructor set error display
  587. // $charset_def = null,
  588. // $error_display = true
  589. // $mail -> (&) new Qdmail( Charset , Encoding , DetectOrder , error_display );
  590. //--------------------------------
  591. function __construct( $param = null ){
  592. $this->stack_construct = $param ;
  593. if( !empty( $param[0] ) && !empty( $param[1] ) ){
  594. $this->charset( $param[0] , $param[1] );
  595. }elseif( !empty( $param[0] ) ){
  596. $this->charset( $param[0] );
  597. }
  598. if( !empty( $param[2] ) ){
  599. $this->detect_order = $param[1];
  600. }
  601. if( false !== $this->detect_order ){
  602. $this->qd_detect_order( $this->detect_order );
  603. }
  604. if( !empty( $param[3] ) ){
  605. $this->error_display = $param[2];
  606. }
  607. if(is_null($this->LFC)){
  608. $this->LFC = chr(13) . chr(10);
  609. }
  610. if(is_null($this->LFC_Qmail)){
  611. $this->LFC_Qmail = chr(10);
  612. }
  613. if($this->isQmail()){
  614. $this->LFC = $this->LFC_Qmail;
  615. }
  616. $this->optionNameLink();
  617. $this->wordwrapProhibitConstruct();
  618. $this->sendmail_path = ini_get("sendmail_path");
  619. }
  620. function & getInstance(){
  621. static $instance = array();
  622. if( isset($instance[0]) && is_object($instance[0]) ){
  623. $keep = $instance[0]->keep_parameter;
  624. if( is_string($keep[0]) ){
  625. $stack = array();
  626. foreach($keep as $method){
  627. if( !is_string( $method ) || !method_exists( $instance[0] , $method ) ){
  628. continue;
  629. }
  630. $stack[$method] = $instance[0]->{$method}();
  631. }
  632. $instance[0] -> reset();
  633. foreach($stack as $method => $value){
  634. $instance[0]->{$method}($value);
  635. }
  636. }elseif( true !== $keep[0] ){
  637. $instance[0] -> reset();
  638. }
  639. return $instance[0];
  640. }
  641. $instance[0] = & new Qdmail();
  642. return $instance[0];
  643. }
  644. //--------------------------
  645. // Decoration Mail Template
  646. //--------------------------
  647. function makeDecoTemplate( $deco_kind , $content ){
  648. if(false===($this->deco_kind=$this->decoSelect( $deco_kind ))){
  649. return $this->errorGather('Illegal Decoration Kind \''.$deco_kind.'\'',__LINE__);
  650. }
  651. $DECO = new QdDeco;
  652. $DECO -> template($content);
  653. $DECO -> decode();
  654. $content = $DECO -> get('HTML');
  655. $attach = $DECO -> get('ATTACH');
  656. $this -> renderMode( true );
  657. $this -> to('dummy@example.com');
  658. $this -> from('dummy@example.com');
  659. $this -> subject('dummy_subject');
  660. $this->body = null;
  661. $this->after_id = null;
  662. $this->content_id_fix = true;
  663. $this->is_html = 'HTML';
  664. $count = 0;
  665. $content = $this->qd_convert_encoding($content,'utf-8',$this->qd_detect_encoding($content));
  666. $content=preg_replace('/\r?\n/','',$content);
  667. foreach($attach as $key => $att){
  668. if( empty( $attach[$key]['CONTENT-ID'] ) ){
  669. continue;
  670. }
  671. $aft = isset($this->deco_def[$this->deco_kind]['CID_AFTER']) ? $this->deco_def[$this->deco_kind]['CID_AFTER']:'';
  672. $prefix = isset($this->deco_def[$this->deco_kind]['CID_PREFIX']) ? $this->deco_def[$this->deco_kind]['CID_PREFIX']:'';
  673. $col_num = isset($this->deco_def[$this->deco_kind]['CID_NUM_COL']) ? $this->deco_def[$this->deco_kind]['CID_NUM_COL']:3;
  674. $ct = '00'.$count++;
  675. $start = (strlen($ct)-$col_num) < 0 ? 0:strlen($ct)-$col_num;
  676. $end = strlen($ct)-$start;
  677. $new_cid = $prefix
  678. . substr($ct,$start,$end)
  679. . $aft;
  680. $content=preg_replace('/<\s*IMG\s+SRC\s*=\s*"cid:'.$attach[$key]['CONTENT-ID'].'"/is','<IMG SRC="cid:'.$new_cid.'"',$content);
  681. $attach[$key]['CONTENT-ID'] = $new_cid;
  682. }
  683. $this->html( $content , null , null , 'utf-8' );
  684. if( 0 < count($attach) ){
  685. $this->attach( $attach );
  686. }
  687. $this->createMail(
  688. $this->deco_def[$this->deco_kind]['BOUNDARY'],
  689. true
  690. );
  691. $header = '';
  692. foreach($this->deco_def[$this->deco_kind]['TOP'] as $line){
  693. $header .= $line .$this->LFC;
  694. }
  695. $header .= 'MIME-Version: 1.0' . $this->LFC
  696. . 'Content-type: ' . key($this->structure[$this->deco_def[$this->deco_kind]['STRUCTURE']])
  697. . '; boundary="'.$this->deco_def[$this->deco_kind]['BOUNDARY'] . '"'
  698. . $this->LFC;
  699. return $header . $this->LFC . $this -> smtpDataBody() . $this->LFC ;
  700. }
  701. //-------------------
  702. // Easy Base
  703. //-------------------
  704. function easy( $type , $to , $subject , $content , $other_header = array() , $attach = null ){
  705. if(is_null($other_header)){
  706. $other_header=array();
  707. }
  708. $this->resetHeaderBody();
  709. $option_return = array();
  710. if( is_array($type) ){
  711. $type = array_change_key_case( $type , CASE_UPPER );
  712. if( isset( $type['SMTP'] ) ){
  713. $this->smtp( true );
  714. $this->smtpServer( $type['SMTP'] );
  715. }
  716. if(isset( $type['OPTION'] )){
  717. $type['OPTION'] = array_change_key_case( $type['OPTION'] , CASE_UPPER );
  718. foreach($type['OPTION'] as $method => $param ){
  719. if(method_exists($this,$method)){
  720. $option_return[$method] = $this->{$method}($param);
  721. }
  722. }
  723. }
  724. $type = isset( $type['TYPE'] ) ? $type['TYPE'] : 'TEXT' ;
  725. }
  726. if( (empty($to) && ( !empty($subject) || !empty($content) ))){
  727. return $this->errorGather('Parameter Specified Error',__LINE__);
  728. }elseif( empty($to) ){
  729. return $option_return;
  730. }
  731. if( 'TEXT' == strtoupper( $type ) || 'HTML' == strtoupper( $type ) ){
  732. $type=strtolower( $type );
  733. }else{
  734. $this->error[]='Illegal spcify \'type\' in '.$type.' .'.__LINE__;
  735. return $this->errorGather();
  736. }
  737. $to = is_string($to) ? array($to) : $to ;
  738. $other_header = is_string($other_header) ? array('From' => $other_header) : $other_header ;
  739. list($other_header_temp , $link ) = $this->keyUpper( $other_header );
  740. if(!isset($other_header_temp['FROM'])){
  741. $fromAddr = null;
  742. if( isset($other_header[0]) ){
  743. $fromAddr = $other_header[0];
  744. unset($other_header[0]);
  745. }
  746. $fromName = null;
  747. if(isset($other_header[1])){
  748. $fromName = $other_header[1];
  749. unset($other_header[1]);
  750. }
  751. if(!empty($fromAddr)){
  752. $other_header = array_merge( $other_header,array('FROM'=>array( $fromAddr , $fromName )));
  753. }
  754. }
  755. $other_header = array_merge(array('TO'=>$to),$other_header);
  756. $section = array('TO'=>'to','CC'=>'cc','BCC'=>'bcc','REPLY-TO'=>'replyto','FROM'=>'from');
  757. list($other_header_temp , $link ) = $this->keyUpper( $other_header );
  758. foreach($other_header_temp as $key => $other_head){
  759. if(isset($section[$key])){
  760. $method = $section[$key];
  761. $this -> {$method}( $other_head , null );
  762. }else{
  763. $this -> addHeader( $link[$key] , $other_head );
  764. }
  765. }
  766. $this->subject( $subject );
  767. $this->{$type}( $content );
  768. if( isset( $attach ) ){
  769. $this->attach( $attach , $add = false , $this->inline_mode );
  770. }
  771. return $this->send();
  772. }
  773. function easyText( $to , $subject , $content , $other_header = array() , $attach = null , $option = array() ){
  774. return $this->easy( array('TYPE'=>'text','OPTION'=>$option) , $to , $subject , $content , $other_header , $attach );
  775. }
  776. function easyHtml( $to , $subject , $content , $other_header = array() , $attach = null , $option = array() ){
  777. return $this->easy( array('TYPE'=>'html','OPTION'=>$option) , $to , $subject , $content , $other_header , $attach );
  778. }
  779. function easyReplace( $to , $subject , $content , $other_header = array() , $attach = null , $option = array() ){
  780. $this->simpleReplace( true );
  781. $type = 'text';
  782. if(0!==count($option)){
  783. $option = array_change_key_case( $option , CASE_UPPER );
  784. $type = ( 'HTML' === strtoupper( $option['TYPE']) ) ? 'html' : $type ;
  785. }
  786. $this->easy( array('TYPE'=>$type,'OPTION'=>$option) , $to , $subject , $content , $other_header , $attach );
  787. }
  788. function easyDeco( $to , $subject , $content , $other_header = array() , $attach = null , $option = array() ){
  789. if( isset( $attach ) ){
  790. $this->inline_mode=true;
  791. }
  792. $this->autoDecoJudge( true );
  793. $this->toSeparate( true );
  794. return $this->easy( array('TYPE'=>'html','OPTION'=>$option) , $to , $subject , $content , $other_header , $attach );
  795. }
  796. function easyDecoTemplate( $to , $subject , $template , $other_header = array() , $attach = null , $option = array() ){
  797. if(is_null($attach)){
  798. $attach = array();
  799. }
  800. $DECO = new QdDeco;
  801. $DECO -> template($template);
  802. $DECO -> decode();
  803. $content = $DECO -> get('HTML');
  804. $text = $DECO -> get('PLAIN');
  805. if(!empty($text)){
  806. $this->text($text);
  807. }
  808. $att = $DECO ->get('ATTACH');
  809. $attach = array_merge($att,$attach);
  810. return $this->easyDeco( $to , $subject , $content , $other_header , $attach , $option );
  811. }
  812. function easyDecoRep( $to , $subject , $content , $other_header = array() , $attach = null , $option = array() ){
  813. $this->simpleReplace( true );
  814. return $this->easyDeco($to , $subject , $content , $attach , $option , $option);
  815. }
  816. function easyOption( $to , $subject = null , $content = null , $other_header = array() , $attach = null , $option = array() ){
  817. if(!is_array($to)){
  818. $option = array( $to => $subject );
  819. }else{
  820. $option = $to;
  821. }
  822. return $this->easy( array('TYPE'=>'option','OPTION'=>$option) , $to , $subject , $content , $other_header , $attach );
  823. }
  824. /*
  825. * Notice: Before use $this->optionNameLink(); by Constractor
  826. */
  827. //
  828. //---------------------------------------
  829. // something change mode
  830. //---------------------------------------
  831. // Keys must lowercase , because of PHP4's
  832. var $property_type = array(
  833. 'auto_both' => 'bool' ,
  834. 'to_separate' => 'bool' ,
  835. 'simple_replace' => 'bool' ,
  836. 'auto_deco_judge' => 'bool' ,
  837. 'auto_ext' => 'bool' ,
  838. 'body_empty_allow' => 'bool' ,
  839. 'ignore_error' => 'bool' ,
  840. 'wrap_width' => 'bool' ,
  841. 'wordwrap_allow' => 'bool' ,
  842. 'wrap_prohibit_allow'=> 'bool' ,
  843. 'force_change_charset' => 'bool' ,
  844. 'error_display' => 'bool' ,
  845. 'sendmail' => 'bool' ,
  846. 'smtp' => 'bool' ,
  847. 'smtp_loglevel_link'=> 'bool' ,
  848. 'inline_mode' => 'bool' ,
  849. 'replace_with_to_priority'=> 'bool' ,
  850. 'attach_build_once' => 'bool' ,
  851. 'body_build_once' => 'bool' ,
  852. 'kana' => 'bool' ,
  853. 'render_mode' => 'bool' ,
  854. 'smime' => 'bool' ,
  855. 'pgp' => 'bool' ,
  856. 'simple_attach' => 'bool' ,
  857. 'message_id' => 'bool' ,
  858. 'allow_blank_header'=> 'bool' ,
  859. 'sign' => 'string' ,
  860. 'keep_parameter' => 'array' ,
  861. 'attach_path' => 'string' ,
  862. 'mta_option' => 'string' ,
  863. 'rep_prefix' => 'string' ,
  864. 'log_path' => 'string' ,
  865. 'errorlog_path' => 'string' ,
  866. 'log_filename' => 'string' ,
  867. 'errorlog_filename' => 'string' ,
  868. 'allways_bcc' => 'string' ,
  869. 'wrap_prohibit_top' => 'string' ,
  870. 'wrap_prohibit_end' => 'string' ,
  871. 'framework' => 'string' ,
  872. 'priority' => 'string' ,
  873. 'certificate_file' => 'string' ,
  874. 'certificate_file_path' => 'string' ,
  875. 'certificate_temp_path' => 'string' ,
  876. 'time_zone' => 'string' ,
  877. 'private_key_file' => 'string' ,
  878. 'certificate_pass' => 'string' ,
  879. 'message_id_right' => 'string' ,
  880. 'sendmail_path' => 'string' ,
  881. 'temporary_path' => 'string' ,
  882. 'united_charset' => 'string' ,
  883. 'varidate_address_regex'=> 'string' ,
  884. 'mb_strwidth_magni' => 'numeric' ,
  885. 'log_dateformat' => 'numeric' ,
  886. 'log_level' => 'numeric' ,
  887. 'errorlog_level' => 'numeric' ,
  888. 'mime_encode_max' => 'numeric' ,
  889. 'smtp_server' => 'array' ,
  890. 'address_validation_method'=> 'array',
  891. );
  892. var $method_property = array();
  893. function optionNameLink(){
  894. foreach($this->property_type as $prop => $type ){
  895. $method_low = strtolower( str_replace( '_' , '' , $prop ) );
  896. $this->method_property[$method_low] = $prop;
  897. }
  898. }
  899. function option( $option , $line = null , $min = null , $max = null ){
  900. $ret = array();
  901. if( !is_null( $line ) ){
  902. $line = '-' . $line ;
  903. }
  904. if(!is_array($option)){
  905. return $this->errorSpecify( __FUNCTION__, __LINE__ );
  906. }
  907. foreach( $option as $key => $value ){
  908. if( !isset( $this->method_property[strtolower($key)] ) ){
  909. return $this->errorSpecify( __FUNCTION__ . '-' .$key , __LINE__ . $line );
  910. }
  911. $property_name = $this->method_property[strtolower($key)];
  912. if( is_null( $value ) ){
  913. $ret[] = $this->{$property_name} ;
  914. continue ;
  915. }
  916. $err = false;
  917. switch( $this->property_type[$property_name] ){
  918. case 'bool':
  919. if( is_bool( $value ) ){
  920. $this->{$property_name} = $value ;
  921. $ret[0] = true ;
  922. }else{
  923. return $this->errorSpecify( __FUNCTION__ . '-' .$key , __LINE__ . $line );
  924. }
  925. break;
  926. case 'string':
  927. if( '' === $value ){
  928. $this->{$property_name} = null ;
  929. $ret[0] = true ;
  930. break ;
  931. }
  932. if( is_string( $value ) ){
  933. $this->{$property_name} = $value ;
  934. $ret[0] = true ;
  935. }else{
  936. return $this->errorSpecify( __FUNCTION__ . '-' .$key , __LINE__ . $line );
  937. }
  938. break;
  939. case 'numeric':
  940. if( !is_numeric( $value ) || ( isset( $min ) && ( $value < $min ) ) || ( isset( $max ) && ( $value > $max ) ) ){
  941. return $this->errorSpecify( __FUNCTION__ . '-' .$key , __LINE__ . $line );
  942. }else{
  943. $this->{$property_name} = $value ;
  944. $ret[0] = true ;
  945. }
  946. break;
  947. case 'array':
  948. if( !is_array( $value ) ){
  949. $value = array( $value );
  950. }
  951. if( true===$min ){
  952. $this->{$property_name} = array_merge( $this->{$property_name} , $value );
  953. }else{
  954. $this->{$property_name} = $value ;
  955. }
  956. $ret[0] = true ;
  957. if( true === $max ){
  958. $this->{$property_name} = array_change_key_case( $this->{$property_name} , CASE_UPPER );
  959. }
  960. break;
  961. default:
  962. return $this->errorSpecify( __FUNCTION__ . '-' .$key , __LINE__ . $line );
  963. break;
  964. }
  965. }
  966. if( 0 === count( $ret ) ){
  967. return $this->errorSpecify( __FUNCTION__ , __LINE__ );
  968. }elseif( 1 === count( $ret ) ){
  969. return array_shift( $ret );
  970. }else{
  971. return $ret ;
  972. }
  973. }
  974. function autoBoth( $bool = null ){
  975. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  976. }
  977. function toSeparate( $bool = null ){
  978. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  979. }
  980. function simpleReplace( $bool = null ){
  981. $this->toSeparate( $bool );
  982. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  983. }
  984. function autoDecoJudge( $bool = null ){
  985. $this->attachBuildOnce( !$bool );
  986. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  987. }
  988. function autoExt( $bool = null ){
  989. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  990. }
  991. function bodyEmptyAllow( $bool = null ){
  992. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  993. }
  994. function ignoreError( $bool = null ){
  995. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  996. }
  997. function forceChangeCharset( $bool = null ){
  998. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  999. }
  1000. function errorDisplay( $bool = null ){
  1001. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  1002. }
  1003. function sendmail( $bool = null ){
  1004. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  1005. }
  1006. function smtp( $bool = null ){
  1007. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  1008. }
  1009. function smtpLoglevelLink( $bool = null ){
  1010. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  1011. }
  1012. function inlineMode( $bool = null ){
  1013. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  1014. }
  1015. function replaceWithToPriority( $bool = null ){
  1016. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  1017. }
  1018. function attachBuildOnce( $bool = null ){
  1019. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  1020. }
  1021. function bodyBuildOnce( $bool = null ){
  1022. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  1023. }
  1024. function kana( $bool = null ){
  1025. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  1026. }
  1027. function keepParameter( $bool = null ){
  1028. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  1029. }
  1030. function renderMode( $bool = null ){
  1031. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  1032. }
  1033. function simpleAttach( $bool = null ){
  1034. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  1035. }
  1036. function messageId( $bool = null ){
  1037. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  1038. }
  1039. function allowBlankHeader( $bool = null ){
  1040. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  1041. }
  1042. function smime( $bool = null ){
  1043. $fg = $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  1044. if(!extension_loaded ( 'openssl' )){
  1045. $this->smime = false;
  1046. if(!$bool){
  1047. return false;
  1048. }
  1049. }
  1050. return $fg;
  1051. }
  1052. function pgp( $bool = null ){
  1053. // future
  1054. return true;
  1055. }
  1056. function sign( $string = null ){
  1057. if(false===$string){
  1058. $this->smime = false;
  1059. $this->pgp = false;
  1060. $this->sign = false;
  1061. return true;
  1062. }
  1063. if(empty($string)){
  1064. return $this->sign;
  1065. }
  1066. $string = strtoupper($string);
  1067. if('S/MIME'==$string){
  1068. $this->smime(true);
  1069. }elseif('PGP'==$string){
  1070. $this->pgp(true);
  1071. }else{
  1072. return false;
  1073. }
  1074. $fg = $this->option( array( __FUNCTION__ => $string ) ,__LINE__);
  1075. return $fg;
  1076. }
  1077. function size( $kind = null ){
  1078. if(empty($this->header_for_smtp)){
  1079. $stack = $this->render_mode;
  1080. $this->render_mode = true;
  1081. $fg = $this->send();
  1082. $this->render_mode = $stack;
  1083. }
  1084. $this->size['ALL'] = strlen( bin2hex( $this->header_for_smtp . $this->LFC . $this->content_for_mailfunction )) / 2;
  1085. $this->size['HEADER'] = strlen( bin2hex( $this->header_for_smtp )) / 2;
  1086. $this->size['BODY'] = strlen( bin2hex( $this->content_for_mailfunction )) / 2;
  1087. if(is_null($kind)){
  1088. return $this->size;
  1089. }
  1090. $kind = strtoupper( $kind );
  1091. if(isset($this->size[$kind])){
  1092. return $this->size[$kind];
  1093. }
  1094. return false;
  1095. }
  1096. function sizeAll(){
  1097. return $this->size('ALL');
  1098. }
  1099. function sizeHeader(){
  1100. return $this->size('HEADER');
  1101. }
  1102. function sizeBody(){
  1103. return $this->size('BODY');
  1104. }
  1105. function smtpData(){
  1106. if(empty($this->header_for_smtp)){
  1107. $stack = $this->render_mode;
  1108. $this->render_mode = true;
  1109. $fg = $this->send();
  1110. $this->render_mode = $stack;
  1111. }
  1112. return $this->header_for_smtp . $this->LFC . $this->content_for_mailfunction ;
  1113. }
  1114. function smtpDataBody(){
  1115. if(empty($this->content_for_mailfunction)){
  1116. $stack = $this->render_mode;
  1117. $this->render_mode = true;
  1118. $fg = $this->send();
  1119. $this->render_mode = $stack;
  1120. }
  1121. return $this->content_for_mailfunction ;
  1122. }
  1123. function isQmail(){
  1124. if(!is_null($this->is_qmail)){
  1125. return $this->is_qmail;
  1126. }
  1127. $this->is_qmail = false;
  1128. $ret = ini_get ( 'sendmail_path' );
  1129. if(false !== strpos($ret,'qmail')){
  1130. $this->is_qmail = true;
  1131. }
  1132. $sendmail_path = ini_get('sendmail_path');
  1133. if(false !== @system($sendmail_path.' -d0.1 < /dev/null > /dev/null',$ret)){
  1134. if(is_array($ret)){
  1135. $ret = reset($ret);
  1136. }
  1137. $code = (int) substr($ret,0,3);
  1138. if( 100 === $code || 111 === $code){
  1139. $this->is_qmail = true;
  1140. }
  1141. }
  1142. return $this->is_qmail ;
  1143. }
  1144. function lineFeed( $LFC = null ){
  1145. if(is_null($LFC)){
  1146. return $this->LFC;
  1147. }
  1148. if(preg_match('/[\r|\n|\r\n]/is',$LFC)){
  1149. $this->LFC = $LFC;
  1150. return true;
  1151. }else{
  1152. return false;
  1153. }
  1154. }
  1155. function isWin(){
  1156. return false!==strpos(PHP_OS,'WIN');
  1157. }
  1158. //---------------------------------------
  1159. // something change mode
  1160. //---------------------------------------
  1161. function whichTextHtml( $which ){
  1162. $which = strtoupper( $which );
  1163. if( 'TEXT' == $which ){
  1164. $this->is_html='TEXT';
  1165. }elseif( 'HTML' == $which ){
  1166. $this->is_html='HTML';
  1167. }elseif( 'BOTH' == $which ){
  1168. $this->is_html='BOTH';
  1169. }
  1170. }
  1171. function allwaysBcc( $option = null ){
  1172. if( is_null( $option ) ){
  1173. return $this->allways_bcc ;
  1174. }
  1175. if( $this->option( array( __FUNCTION__ => $option ) ,__LINE__) ){
  1176. $fg = $this->extractAddr( $this->allways_bcc ) ;
  1177. }
  1178. if( $this->errorGather() && $fg && !empty($this->allways_bcc) ){
  1179. return true ;
  1180. }else{
  1181. $this->allways_bcc = array();
  1182. return false ;
  1183. }
  1184. }
  1185. function priority( $option = null ){
  1186. $fg=$this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1187. $priority = strtoupper($option);
  1188. if(empty($priority)){
  1189. return $fg;
  1190. }
  1191. $kind = array('HIGH'=>1,'NORMAL'=>1,'LOW'=>1);
  1192. if( !isset( $kind[$priority] ) ){
  1193. return $this->errorGather('Illegal Priority Name \''.$option.'\'',__LINE__);
  1194. }
  1195. foreach($this->priority_def as $header_name => $values){
  1196. $this->addHeader($header_name,$values[$priority]);
  1197. }
  1198. return $this->errorGather();
  1199. }
  1200. function certificatePass( $option = null ){
  1201. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1202. }
  1203. function certificateFilePath( $option = null ){
  1204. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1205. }
  1206. function certificateTempPath( $option = null ){
  1207. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1208. }
  1209. function certificateFile( $option = null ){
  1210. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1211. }
  1212. function privateKeyFile( $option = null ){
  1213. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1214. }
  1215. function framework( $option = null ){
  1216. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1217. }
  1218. function attachPath( $option = null ){
  1219. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1220. }
  1221. function timeZone( $option = null ){
  1222. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1223. }
  1224. function messageIdRight( $option = null ){
  1225. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1226. }
  1227. function mtaOption( $option = null ){
  1228. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1229. }
  1230. function unitedCharset( $option = null ){
  1231. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1232. }
  1233. function varidateAddressRegex( $option = null ){
  1234. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1235. }
  1236. function sendmailPath( $option = null ){
  1237. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1238. }
  1239. function temporaryPath( $option = null ){
  1240. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1241. }
  1242. function logPath( $option = null ){
  1243. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1244. }
  1245. function errorlogPath( $option = null ){
  1246. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1247. }
  1248. function logDateFormat( $option = null ){
  1249. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1250. }
  1251. function logFilename( $option = null ){
  1252. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1253. }
  1254. function errorlogFilename( $option = null ){
  1255. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1256. }
  1257. function logLevel( $option = null ){
  1258. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__, 0 , $this->log_level_max );
  1259. }
  1260. function errorlogLevel( $option = null ){
  1261. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__, 0 , $this->errorlog_level_max );
  1262. }
  1263. function mimeEncodeMax( $option = null ){
  1264. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1265. }
  1266. function smtpServer( $array = null ){
  1267. return $this->option( array( __FUNCTION__ => $array ) ,__LINE__, true , true );
  1268. }
  1269. function addressValidationMethod( $array = null ){
  1270. return $this->option( array( __FUNCTION__ => $array ) ,__LINE__, false , true );
  1271. }
  1272. //------------------
  1273. //version
  1274. //------------------
  1275. function version(){
  1276. return $this->version;
  1277. }
  1278. //------------------
  1279. //mb_ wrapper
  1280. //------------------
  1281. function qd_detect_encoding( $word ){
  1282. if(!is_null($this->united_charset)){
  1283. return $this->united_charset;
  1284. }else{
  1285. return mb_detect_encoding( $word , mb_detect_order() , true );
  1286. }
  1287. }
  1288. function qd_convert_encoding( $word , $target_chrset , $org_charset = null ){
  1289. if(empty($org_charset)){
  1290. $org_charset = $this->qd_detect_encoding( $word );
  1291. }
  1292. if(empty($org_charset)){
  1293. return $word;
  1294. }
  1295. if( strtoupper( $target_chrset ) === strtoupper( $org_charset ) ){
  1296. return $word;
  1297. }
  1298. if('ASCII'===strtoupper( $target_chrset ) || 'ASCII'===strtoupper( $org_charset )){
  1299. return $word;
  1300. }
  1301. return mb_convert_encoding( $word , $target_chrset , $org_charset );
  1302. }
  1303. function qd_detect_order( $param=null ){
  1304. if(is_null($param)){
  1305. return mb_detect_order();
  1306. }else{
  1307. return mb_detect_order( $param );
  1308. }
  1309. }
  1310. //-----------------------------------------
  1311. // Address and Name Keys change Opiton
  1312. //-----------------------------------------
  1313. function addressField( $addr = null , $name = null ){
  1314. if( is_null($addr) && is_null($name) ){
  1315. return array( $this->tokey['_ADDR'] , $this->tokey['_NAME'] );
  1316. }
  1317. if( !is_null($addr) && is_array($addr) && 1 < count($addr) ){
  1318. $_addr = array_shift( $addr ) ;
  1319. $name = array_shift( $addr ) ;
  1320. $addr = $_addr;
  1321. }
  1322. if( (!is_null($addr) && !is_string( $addr )) || !is_null($name) && !is_string($name) ){
  1323. return $this->errorGather('Specify Error in addressField',__LINE__);
  1324. }
  1325. $addr = is_null( $addr ) ? $this->tokey['_ADDR'] : $addr ;
  1326. $name = is_null( $name ) ? $this->tokey['_NAME'] : $name ;
  1327. $this->tokey = array(
  1328. '_ADDR' => $addr,
  1329. '_NAME' => $name,
  1330. );
  1331. return true;
  1332. }
  1333. //-----------------------------------------------------------
  1334. // Wordwrap Opiton
  1335. // array( 'except word' => beginning flag )
  1336. // if beginning flag is true , beginning of a line is target
  1337. // if beginning flag is true , the word in line is target
  1338. //-----------------------------------------------------------
  1339. function wordwrapProhibitConstruct(){
  1340. $ret = $this->strToArrayKey( $this->wrap_prohibit_top , true );
  1341. $ret2 = $this->strToArrayKey( $this->wrap_prohibit_end , false );
  1342. $this->wrap_prohibit = array_merge( $ret , $ret2 );
  1343. }
  1344. function strToArrayKey( $word , $value ){
  1345. $ret = array();
  1346. $enc = $this->qd_detect_encoding( $word );
  1347. $length = mb_strlen( $word , $enc );
  1348. for( $i=0 ; $i < $length ; $i++ ){
  1349. $ret[ mb_substr( $word , $i , 1 , $enc ) ] = $value;
  1350. }
  1351. return $ret;
  1352. }
  1353. function wordwrapAllow( $bool = null ){
  1354. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  1355. }
  1356. function wrapProhibitAllow( $bool = null ){
  1357. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  1358. }
  1359. function wrapProhibitEnd( $option = null ){
  1360. $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1361. $this->wordwrapProhibitConstruct();
  1362. return $this->errorGather();
  1363. }
  1364. function wrapProhibitTop( $option = null ){
  1365. $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
  1366. $this->wordwrapProhibitConstruct();
  1367. return $this->errorGather();
  1368. }
  1369. function wrapWidth( $bool = null ){
  1370. return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
  1371. }
  1372. function wordwrapLength( $length = null ){
  1373. if( is_null( $length ) ){
  1374. return $this->wordwrap_length;
  1375. }
  1376. if( !is_numeric( $length ) || ( is_numeric( $length ) && $length < 1 ) ){
  1377. return $this->errorGather('Wordwrap error , length is illegal' ,__LINE__) ;
  1378. }
  1379. $this->wordwrap_length = $length;
  1380. return $this->errorGather() ;
  1381. }
  1382. function mbStrwidthMagni( $option = null ){
  1383. return $this->option( array( __FUNCTION__ => $option ) ,__LINE__, 0 , 10 );
  1384. }
  1385. function wrapExcept( $array = null ){
  1386. if( null === $array ){
  1387. return $this->wrap_except;
  1388. }
  1389. if( is_string( $array ) || is_numeric( $array ) ){
  1390. $this->wrap_except = array( $array =>false );//default false
  1391. }
  1392. if( is_array( $array ) ){
  1393. if( 0 === count( $array ) ){
  1394. $this->wrap_except = array();
  1395. return $this->errorGather() ;
  1396. }
  1397. foreach( $array as $key => $value){
  1398. if( !is_bool( $value ) ){
  1399. $array[$key] = empty( $value ) ? false:true;
  1400. }else{
  1401. $array[$key] = $value ;
  1402. }
  1403. }
  1404. $this->wrap_except = $array;
  1405. return $this->errorGather() ;
  1406. }
  1407. return $this->errorSpecify(__FUNCTION__,__LINE__);
  1408. }
  1409. //------------------------------------------
  1410. // Charset Option
  1411. //------------------------------------------
  1412. function charsetHeader( $charset = null ){
  1413. if(is_null($charset)){
  1414. return $this->charset_header ;
  1415. }
  1416. $stack = $this->charset();
  1417. $stack['HEADER'] = $charset;
  1418. return $this->charset( $stack );
  1419. }
  1420. function charsetAttach( $charset = null ){
  1421. if(is_null($charset)){
  1422. return $this->charset_attach_filename ;
  1423. }
  1424. $stack = $this->charset();
  1425. $stack['HEADER'] = $charset;
  1426. return $this->charset( $stack );
  1427. }
  1428. function charsetBody( $charset = null , $enc = null ){
  1429. if( is_null($charset) && is_null($enc) ){
  1430. return array($this->charset_content , $this->content_transfer_enc_text , content_transfer_enc_html) ;
  1431. }
  1432. if(is_array($charset)){
  1433. $enc = isset($charset[1]) ? $charset[1]:null;
  1434. $charset = $charset[0];
  1435. }
  1436. $stack = $this->charset();
  1437. if( !is_null($charset) ){
  1438. $stack['BODY'] = $charset;
  1439. }
  1440. if( !is_null($enc) ){
  1441. $stack['HTML'] = $stack['TEXT'] = $enc;
  1442. }
  1443. return $this->charset( $stack );
  1444. }
  1445. function charset( $array = null , $op = null ){
  1446. if( is_null( $array ) && is_null( $op ) ){
  1447. foreach( $this->corres_charset as $key => $value ){
  1448. $ret[$key] = $this->{$value} ;
  1449. }
  1450. return $ret;
  1451. }
  1452. if( !is_null($op) && is_string($op) ){
  1453. $this->content_transfer_enc_text = $op ;
  1454. $this->content_transfer_enc_html = $op ;
  1455. return $this->charset( $array );
  1456. }elseif(!is_null($op) && !is_string($op)){
  1457. return $this->errorSpecify( __FUNCTION__ , __LINE__ );
  1458. }
  1459. if( is_array( $array ) ){
  1460. if( 2===count($array) && isset($array[0]) && isset($array[1])){
  1461. return $this->charset($array[0],$array[1]);
  1462. }
  1463. $array = array_change_key_case( $array , CASE_UPPER );
  1464. foreach( $array as $key => $value ){
  1465. if(isset($this->corres_charset[$key])){
  1466. if( is_string($this->corres_charset[$key]) ){
  1467. $this->{$this->corres_charset[$key]} = $value;
  1468. }else{
  1469. return $this->errorSpecify( __FUNCTION__ , __LINE__ );
  1470. }
  1471. }
  1472. }
  1473. }elseif( is_string($array) ){
  1474. $this->charset_header = $this->charset_content = $this->charset_attach_filename = $array;
  1475. }else{
  1476. return $this->errorSpecify( __FUNCTION__ , __LINE__ );
  1477. }
  1478. return $this->errorGather() ;
  1479. }
  1480. function encoding( $enc = null ){
  1481. if(is_null($enc)){
  1482. return $this->corres_charset['TEXT'];
  1483. }
  1484. $this->corres_charset['TEXT'] = $this->corres_charset['HTML'] = $enc;
  1485. return true;
  1486. }
  1487. //--------------------------
  1488. // set Mutibye Parameter
  1489. //--------------------------
  1490. function setMbParameter( $lang = null , $internal_enc = null , $detect = null ){
  1491. if(is_array($lang)){
  1492. mb_language( $lang[0] ) ;
  1493. mb_internal_encoding( $lang[1] ) ;
  1494. $this->qd_detect_order( $lang[2] );
  1495. }elseif( 'STACK'===strtoupper($lang) ){
  1496. $this->mb_parameter_stack = array(mb_language(),mb_internal_encoding(),$this->qd_detect_order());
  1497. mb_language( $this->lang_def );
  1498. mb_internal_encoding( $this->encoding_def );
  1499. $this->qd_detect_order( $this->detect_def );
  1500. }else{
  1501. if( !is_null( $lang ) ){
  1502. mb_language( $lang ) ;
  1503. }
  1504. if( !is_null( $internal_enc ) ){
  1505. mb_internal_encoding( $internal_enc ) ;
  1506. }
  1507. if( !is_null( $detect ) ){
  1508. $this->qd_detect_order( $detect );
  1509. }
  1510. }
  1511. }
  1512. //--------------------------------
  1513. // Decorationable HTML Mail Opiton
  1514. // ( Inline HTML , MHTML )
  1515. // See $this->deco_def Property
  1516. //--------------------------------
  1517. // Change decoration default along to each career
  1518. function decoDef( $value = null ){
  1519. if( is_null( $value ) ){
  1520. return $this->deco_def_default;
  1521. }
  1522. $this->deco_def_default = $value ;
  1523. return $this->errorGather() ;
  1524. }
  1525. // fix Decoration Pattern by STRING means CareerName
  1526. function decoFix( $cari = null ){
  1527. if(is_null($cari)){
  1528. return $this->deco_kind;
  1529. }
  1530. $this->deco_kind = $this->decoSelect( $cari );
  1531. return true;
  1532. }
  1533. function decoSelect( $deco_kind = null ){
  1534. if( is_null( $deco_kind ) ){
  1535. return $this->deco_def_default;//$this->deco_judge
  1536. }
  1537. $deco_kind = strtoupper( $deco_kind );
  1538. $ret = false ;
  1539. foreach( $this->deco_def as $key => $def ){
  1540. if( in_array( $deco_kind , $def['OPTION_NAME'] ) ){
  1541. $ret = $key ;
  1542. $this->inline_mode = true;
  1543. }
  1544. }
  1545. return $ret;
  1546. }
  1547. // Change Decoration Pattern by E-mail Address
  1548. function decoJudge( $addr_array ){
  1549. $addr=$addr_array[$this->tokey['_ADDR']];
  1550. $start =

Large files files are truncated, but you can click here to view the full file