smtps.class.php 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992
  1. <?php
  2. /*
  3. * Copyright (C) Walter Torres <walter@torres.ws> [with a *lot* of help!]
  4. * Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2006-2011 Regis Houssin
  6. * Copyright (C) 2016 Jonathan TISSEAU <jonathan.tisseau@86dev.fr>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/core/class/smtps.class.php
  23. * \brief Class to construct and send SMTP compliant email, even to a secure
  24. * SMTP server, regardless of platform.
  25. * Goals:
  26. * - mime compliant
  27. * - multiple Reciptiants
  28. * - TO
  29. * - CC
  30. * - BCC
  31. * - multi-part message
  32. * - plain text
  33. * - HTML
  34. * - inline attachments
  35. * - attachments
  36. * - GPG access
  37. * This Class is based off of 'SMTP PHP MAIL' by Dirk Paehl, http://www.paehl.de
  38. */
  39. /**
  40. * Class to construct and send SMTP compliant email, even
  41. * to a secure SMTP server, regardless of platform.
  42. */
  43. class SMTPs
  44. {
  45. /**
  46. * Host Name or IP of SMTP Server to use
  47. */
  48. var $_smtpsHost = 'localhost';
  49. /**
  50. * SMTP Server Port definition. 25 is default value
  51. * This can be defined via a INI file or via a setter method
  52. */
  53. var $_smtpsPort = '25';
  54. /**
  55. * Secure SMTP Server access ID
  56. * This can be defined via a INI file or via a setter method
  57. */
  58. var $_smtpsID = null;
  59. /**
  60. * Secure SMTP Server access Password
  61. * This can be defined via a INI file or via a setter method
  62. */
  63. var $_smtpsPW = null;
  64. /**
  65. * Who sent the Message
  66. * This can be defined via a INI file or via a setter method
  67. */
  68. var $_msgFrom = null;
  69. /**
  70. * Where are replies and errors to be sent to
  71. * This can be defined via a INI file or via a setter method
  72. */
  73. var $_msgReplyTo = null;
  74. /**
  75. * Who will the Message be sent to; TO, CC, BCC
  76. * Multi-diminsional array containg addresses the message will
  77. * be sent TO, CC or BCC
  78. */
  79. var $_msgRecipients = null;
  80. /**
  81. * Message Subject
  82. */
  83. var $_msgSubject = null;
  84. /**
  85. * Message Content
  86. */
  87. var $_msgContent = null;
  88. /**
  89. * Custom X-Headers
  90. */
  91. var $_msgXheader = null;
  92. /**
  93. * Character set
  94. * Defaulted to 'iso-8859-1'
  95. */
  96. var $_smtpsCharSet = 'iso-8859-1';
  97. /**
  98. * Message Sensitivity
  99. * Defaults to ZERO - None
  100. */
  101. var $_msgSensitivity = 0;
  102. /**
  103. * Message Sensitivity
  104. */
  105. var $_arySensitivity = array ( false,
  106. 'Personal',
  107. 'Private',
  108. 'Company Confidential' );
  109. /**
  110. * Message Sensitivity
  111. * Defaults to 3 - Normal
  112. */
  113. var $_msgPriority = 3;
  114. /**
  115. * Message Priority
  116. */
  117. var $_aryPriority = array ( 'Bulk',
  118. 'Highest',
  119. 'High',
  120. 'Normal',
  121. 'Low',
  122. 'Lowest' );
  123. /**
  124. * Content-Transfer-Encoding
  125. * Defaulted to 0 - 7bit
  126. */
  127. var $_smtpsTransEncodeType = 0;
  128. /**
  129. * Content-Transfer-Encoding
  130. */
  131. var $_smtpsTransEncodeTypes = array( '7bit', // Simple 7-bit ASCII
  132. '8bit', // 8-bit coding with line termination characters
  133. 'base64', // 3 octets encoded into 4 sextets with offset
  134. 'binary', // Arbitrary binary stream
  135. 'mac-binhex40', // Macintosh binary to hex encoding
  136. 'quoted-printable', // Mostly 7-bit, with 8-bit characters encoded as "=HH"
  137. 'uuencode' ); // UUENCODE encoding
  138. /**
  139. * Content-Transfer-Encoding
  140. * Defaulted to '7bit'
  141. */
  142. var $_smtpsTransEncode = '7bit';
  143. /**
  144. * Boundary String for MIME seperation
  145. */
  146. var $_smtpsBoundary = null;
  147. /**
  148. * Related Boundary
  149. */
  150. var $_smtpsRelatedBoundary = null;
  151. /**
  152. * Alternative Boundary
  153. */
  154. var $_smtpsAlternativeBoundary = null;
  155. /**
  156. * Determines the method inwhich the message are to be sent.
  157. * - 'sockets' [0] - conect via network to SMTP server - default
  158. * - 'pipe [1] - use UNIX path to EXE
  159. * - 'phpmail [2] - use the PHP built-in mail function
  160. * NOTE: Only 'sockets' is implemented
  161. */
  162. var $_transportType = 0;
  163. /**
  164. * If '$_transportType' is set to '1', then this variable is used
  165. * to define the UNIX file system path to the sendmail execuable
  166. */
  167. var $_mailPath = '/usr/lib/sendmail';
  168. /**
  169. * Sets the SMTP server timeout in seconds.
  170. */
  171. var $_smtpTimeout = 10;
  172. /**
  173. * Determines whether to calculate message MD5 checksum.
  174. */
  175. var $_smtpMD5 = false;
  176. /**
  177. * Class error codes and messages
  178. */
  179. var $_smtpsErrors = null;
  180. /**
  181. * Defines log level
  182. * 0 - no logging
  183. * 1 - connectivity logging
  184. * 2 - message generation logging
  185. * 3 - detail logging
  186. */
  187. var $_log_level = 0;
  188. /**
  189. * Place Class in" debug" mode
  190. */
  191. var $_debug = false;
  192. // DOL_CHANGE LDR
  193. var $log = '';
  194. var $_errorsTo = '';
  195. var $_deliveryReceipt = 0;
  196. var $_trackId = '';
  197. var $_moreInHeader = '';
  198. /**
  199. * Set delivery receipt
  200. *
  201. * @param int $_val Value
  202. * @return void
  203. */
  204. function setDeliveryReceipt($_val = 0)
  205. {
  206. $this->_deliveryReceipt = $_val;
  207. }
  208. /**
  209. * get delivery receipt
  210. *
  211. * @return int Delivery receipt
  212. */
  213. function getDeliveryReceipt()
  214. {
  215. return $this->_deliveryReceipt;
  216. }
  217. /**
  218. * Set trackid
  219. *
  220. * @param string $_val Value
  221. * @return void
  222. */
  223. function setTrackId($_val = '')
  224. {
  225. $this->_trackId = $_val;
  226. }
  227. /**
  228. * Set moreInHeader
  229. *
  230. * @param string $_val Value
  231. * @return void
  232. */
  233. function setMoreInHeader($_val = '')
  234. {
  235. $this->_moreinheader = $_val;
  236. }
  237. /**
  238. * get trackid
  239. *
  240. * @return string Track id
  241. */
  242. function getTrackId()
  243. {
  244. return $this->_trackId;
  245. }
  246. /**
  247. * get moreInHeader
  248. *
  249. * @return string moreInHeader
  250. */
  251. function getMoreInHeader()
  252. {
  253. return $this->_moreinheader;
  254. }
  255. /**
  256. * Set errors to
  257. *
  258. * @param string $_strErrorsTo Errors to
  259. * @return void
  260. */
  261. function setErrorsTo($_strErrorsTo)
  262. {
  263. if ( $_strErrorsTo )
  264. $this->_errorsTo = $this->_strip_email($_strErrorsTo);
  265. }
  266. /**
  267. * Get errors to
  268. *
  269. * @param boolean $_part Variant
  270. * @return string Errors to
  271. */
  272. function getErrorsTo($_part = true )
  273. {
  274. $_retValue = '';
  275. if ( $_part === true )
  276. $_retValue = $this->_errorsTo;
  277. else
  278. $_retValue = $this->_errorsTo[$_part];
  279. return $_retValue;
  280. }
  281. /**
  282. * Set debug
  283. *
  284. * @param boolean $_vDebug Value for debug
  285. * @return void
  286. */
  287. function setDebug($_vDebug = false )
  288. {
  289. $this->_debug = $_vDebug;
  290. }
  291. /**
  292. * build RECIPIENT List, all addresses who will recieve this message
  293. *
  294. * @return void
  295. */
  296. function buildRCPTlist()
  297. {
  298. // Pull TO list
  299. $_aryToList = $this->getTO();
  300. }
  301. /**
  302. * Attempt a connection to mail server
  303. *
  304. * @return mixed $_retVal Boolean indicating success or failure on connection
  305. */
  306. function _server_connect()
  307. {
  308. // Default return value
  309. $_retVal = true;
  310. // We have to make sure the HOST given is valid
  311. // This is done here because '@fsockopen' will not give me this
  312. // information if it failes to connect because it can't find the HOST
  313. $host=$this->getHost();
  314. $host=preg_replace('@tcp://@i','',$host); // Remove prefix
  315. $host=preg_replace('@ssl://@i','',$host); // Remove prefix
  316. // DOL_CHANGE LDR
  317. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  318. if ( (! is_ip($host)) && ((gethostbyname($host)) == $host))
  319. {
  320. $this->_setErr(99, $host . ' is either offline or is an invalid host name.');
  321. $_retVal = false;
  322. }
  323. else
  324. {
  325. //See if we can connect to the SMTP server
  326. if ($this->socket = @fsockopen(
  327. $this->getHost(), // Host to 'hit', IP or domain
  328. $this->getPort(), // which Port number to use
  329. $this->errno, // actual system level error
  330. $this->errstr, // and any text that goes with the error
  331. $this->_smtpTimeout
  332. )) // timeout for reading/writing data over the socket
  333. {
  334. // Fix from PHP SMTP class by 'Chris Ryan'
  335. // Sometimes the SMTP server takes a little longer to respond
  336. // so we will give it a longer timeout for the first read
  337. // Windows still does not have support for this timeout function
  338. if (function_exists('stream_set_timeout')) stream_set_timeout($this->socket, $this->_smtpTimeout, 0);
  339. // Check response from Server
  340. if ( $_retVal = $this->server_parse($this->socket, "220") )
  341. $_retVal = $this->socket;
  342. }
  343. // This connection attempt failed.
  344. else
  345. {
  346. // DOL_CHANGE LDR
  347. if (empty($this->errstr)) $this->errstr='Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort();
  348. $this->_setErr($this->errno, $this->errstr);
  349. $_retVal = false;
  350. }
  351. }
  352. return $_retVal;
  353. }
  354. /**
  355. * Attempt mail server authentication for a secure connection
  356. *
  357. * @return boolean|null $_retVal Boolean indicating success or failure of authentication
  358. */
  359. function _server_authenticate()
  360. {
  361. global $conf;
  362. // Send the RFC2554 specified EHLO.
  363. // This improvment as provided by 'SirSir' to
  364. // accomodate both SMTP AND ESMTP capable servers
  365. $host=$this->getHost();
  366. $host=preg_replace('@tcp://@i','',$host); // Remove prefix
  367. $host=preg_replace('@ssl://@i','',$host); // Remove prefix
  368. if (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS))
  369. {
  370. $host=preg_replace('@tls://@i','',$host); // Remove prefix
  371. $host='tls://'.$host;
  372. }
  373. if ( $_retVal = $this->socket_send_str('EHLO ' . $host, '250') )
  374. {
  375. if (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS))
  376. {
  377. /*
  378. The following dialog illustrates how a client and server can start a TLS STARTTLS session
  379. S: <waits for connection on TCP port 25>
  380. C: <opens connection>
  381. S: 220 mail.imc.org SMTP service ready
  382. C: EHLO mail.ietf.org
  383. S: 250-mail.imc.org offers a warm hug of welcome
  384. S: 250 STARTTLS
  385. C: STARTTLS
  386. S: 220 Go ahead
  387. C: <starts TLS negotiation>
  388. C & S: <negotiate a TLS session>
  389. C & S: <check result of negotiation>
  390. // Second pass EHLO
  391. C: EHLO client-domain.com
  392. S: 250-server-domain.com
  393. S: 250 AUTH LOGIN
  394. C: <continues by sending an SMTP command
  395. */
  396. if (!$_retVal = $this->socket_send_str('STARTTLS', 220))
  397. {
  398. $this->_setErr(131, 'STARTTLS connection is not supported.');
  399. return $_retVal;
  400. }
  401. if (!stream_socket_enable_crypto($this->socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT))
  402. {
  403. $this->_setErr(132, 'STARTTLS connection failed.');
  404. return $_retVal;
  405. }
  406. // Most server servers expect a 2nd pass of EHLO after TLS is established to get another time
  407. // the answer with list of supported AUTH methods. They may differs between non STARTTLS and with STARTTLS.
  408. if (!$_retVal = $this->socket_send_str('EHLO '.$host, '250'))
  409. {
  410. $this->_setErr(126, '"' . $host . '" does not support authenticated connections.');
  411. return $_retVal;
  412. }
  413. }
  414. // Send Authentication to Server
  415. // Check for errors along the way
  416. $this->socket_send_str('AUTH LOGIN', '334');
  417. // User name will not return any error, server will take anything we give it.
  418. $this->socket_send_str(base64_encode($this->_smtpsID), '334');
  419. // The error here just means the ID/password combo doesn't work.
  420. // There is not a method to determine which is the problem, ID or password
  421. if ( ! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') )
  422. $this->_setErr(130, 'Invalid Authentication Credentials.');
  423. }
  424. else
  425. {
  426. $this->_setErr(126, '"' . $host . '" does not support authenticated connections.');
  427. }
  428. return $_retVal;
  429. }
  430. /**
  431. * Now send the message
  432. *
  433. * @param boolean $_bolTestMsg whether to run this method in 'Test' mode.
  434. * @param boolean $_bolDebug whether to log all communication between this Class and the Mail Server.
  435. * @return boolean|null void
  436. * $_strMsg If this is run in 'Test' mode, the actual message structure will be returned
  437. */
  438. function sendMsg($_bolTestMsg = false, $_bolDebug = false)
  439. {
  440. /**
  441. * Default return value
  442. */
  443. $_retVal = false;
  444. // Connect to Server
  445. if ( $this->socket = $this->_server_connect() )
  446. {
  447. // If a User ID *and* a password is given, assume Authentication is desired
  448. if( !empty($this->_smtpsID) && !empty($this->_smtpsPW) )
  449. {
  450. // Send the RFC2554 specified EHLO.
  451. $_retVal = $this->_server_authenticate();
  452. }
  453. // This is a "normal" SMTP Server "handshack"
  454. else
  455. {
  456. // Send the RFC821 specified HELO.
  457. $host=$this->getHost();
  458. $host=preg_replace('@tcp://@i','',$host); // Remove prefix
  459. $host=preg_replace('@ssl://@i','',$host); // Remove prefix
  460. $_retVal = $this->socket_send_str('HELO ' . $host, '250');
  461. }
  462. // Well, did we get to the server?
  463. if ( $_retVal )
  464. {
  465. // From this point onward most server response codes should be 250
  466. // Specify who the mail is from....
  467. // This has to be the raw email address, strip the "name" off
  468. $this->socket_send_str('MAIL FROM: ' . $this->getFrom('addr'), '250');
  469. // 'RCPT TO:' must be given a single address, so this has to loop
  470. // through the list of addresses, regardless of TO, CC or BCC
  471. // and send it out "single file"
  472. foreach ( $this->get_RCPT_list() as $_address )
  473. {
  474. /* Note:
  475. * BCC email addresses must be listed in the RCPT TO command list,
  476. * but the BCC header should not be printed under the DATA command.
  477. * http://stackoverflow.com/questions/2750211/sending-bcc-emails-using-a-smtp-server
  478. */
  479. /*
  480. * TODO
  481. * After each 'RCPT TO:' is sent, we need to make sure it was kosher,
  482. * if not, the whole message will fail
  483. * If any email address fails, we will need to RESET the connection,
  484. * mark the last address as "bad" and start the address loop over again.
  485. * If any address fails, the entire message fails.
  486. */
  487. $this->socket_send_str('RCPT TO: <' . $_address . '>', '250');
  488. }
  489. // Tell the server we are ready to start sending data
  490. // with any custom headers...
  491. // This is the last response code we look for until the end of the message.
  492. $this->socket_send_str('DATA', '354');
  493. // Now we are ready for the message...
  494. // Ok, all the ingredients are mixed in let's cook this puppy...
  495. $this->socket_send_str($this->getHeader().$this->getBodyContent() . "\r\n" . '.', '250');
  496. // Now tell the server we are done and close the socket...
  497. fputs($this->socket, 'QUIT');
  498. fclose($this->socket);
  499. }
  500. }
  501. return $_retVal;
  502. }
  503. // =============================================================
  504. // ** Setter & Getter methods
  505. // ** Basic System configuration
  506. /**
  507. * setConfig() is used to populate select class properties from either
  508. * a user defined INI file or the systems 'php.ini' file
  509. *
  510. * If a user defined INI is to be used, the files complete path is passed
  511. * as the method single parameter. The INI can define any class and/or
  512. * user properties. Only properties defined within this file will be setter
  513. * and/or orverwritten
  514. *
  515. * If the systems 'php.ini' file is to be used, the method is called without
  516. * parameters. In this case, only HOST, PORT and FROM properties will be set
  517. * as they are the only properties that are defined within the 'php.ini'.
  518. *
  519. * If secure SMTP is to be used, the user ID and Password can be defined with
  520. * the user INI file, but the properties are not defined with the systems
  521. * 'php.ini'file, they must be defined via their setter methods
  522. *
  523. * This method can be called twice, if desired. Once without a parameter to
  524. * load the properties as defined within the systems 'php.ini' file, and a
  525. * second time, with a path to a user INI file for other properties to be
  526. * defined.
  527. *
  528. * @param mixed $_strConfigPath path to config file or VOID
  529. * @return boolean
  530. */
  531. function setConfig($_strConfigPath = null)
  532. {
  533. /**
  534. * Returns constructed SELECT Object string or boolean upon failure
  535. * Default value is set at TRUE
  536. */
  537. $_retVal = true;
  538. // if we have a path...
  539. if ( ! empty ($_strConfigPath) )
  540. {
  541. // If the path is not valid, this will NOT generate an error,
  542. // it will simply return FALSE.
  543. if ( ! @include ( $_strConfigPath ) )
  544. {
  545. $this->_setErr(110, '"' . $_strConfigPath . '" is not a valid path.');
  546. $_retVal = false;
  547. }
  548. }
  549. // Read the Systems php.ini file
  550. else
  551. {
  552. // Set these properties ONLY if they are set in the php.ini file.
  553. // Otherwise the default values will be used.
  554. if ( $_host = ini_get('SMTPs') )
  555. $this->setHost($_host);
  556. if ( $_port = ini_get('smtp_port') )
  557. $this->setPort($_port);
  558. if ( $_from = ini_get('sendmail_from') )
  559. $this->setFrom($_from);
  560. }
  561. // Send back what we have
  562. return $_retVal;
  563. }
  564. /**
  565. * Determines the method inwhich the messages are to be sent.
  566. * - 'sockets' [0] - conect via network to SMTP server
  567. * - 'pipe [1] - use UNIX path to EXE
  568. * - 'phpmail [2] - use the PHP built-in mail function
  569. *
  570. * @param int $_type Interger value representing Mail Transport Type
  571. * @return void
  572. */
  573. function setTransportType($_type = 0)
  574. {
  575. if ( ( is_numeric($_type) ) &&
  576. ( ( $_type >= 0 ) && ( $_type <= 3 ) ) )
  577. $this->_transportType = $_type;
  578. }
  579. /**
  580. * Return the method inwhich the message is to be sent.
  581. * - 'sockets' [0] - conect via network to SMTP server
  582. * - 'pipe [1] - use UNIX path to EXE
  583. * - 'phpmail [2] - use the PHP built-in mail function
  584. *
  585. * @return int $_strHost Host Name or IP of the Mail Server to use
  586. */
  587. function getTransportType()
  588. {
  589. return $this->_transportType;
  590. }
  591. /**
  592. * Path to the sendmail execuable
  593. *
  594. * @param string $_path Path to the sendmail execuable
  595. * @return boolean
  596. *
  597. */
  598. function setMailPath($_path)
  599. {
  600. // This feature is not yet implemented
  601. return true;
  602. //if ( $_path ) $this->_mailPath = $_path;
  603. }
  604. /**
  605. * Defines the Host Name or IP of the Mail Server to use.
  606. * This is defaulted to 'localhost'
  607. * This is used only with 'socket' based mail transmission
  608. *
  609. * @param string $_strHost Host Name or IP of the Mail Server to use
  610. * @return void
  611. */
  612. function setHost($_strHost)
  613. {
  614. if ( $_strHost )
  615. $this->_smtpsHost = $_strHost;
  616. }
  617. /**
  618. * Retrieves the Host Name or IP of the Mail Server to use
  619. * This is used only with 'socket' based mail transmission
  620. *
  621. * @return string $_strHost Host Name or IP of the Mail Server to use
  622. */
  623. function getHost()
  624. {
  625. return $this->_smtpsHost;
  626. }
  627. /**
  628. * Defines the Port Number of the Mail Server to use
  629. * This is defaulted to '25'
  630. * This is used only with 'socket' based mail transmission
  631. *
  632. * @param int $_intPort Port Number of the Mail Server to use
  633. * @return void
  634. */
  635. function setPort($_intPort)
  636. {
  637. if ( ( is_numeric($_intPort) ) &&
  638. ( ( $_intPort >= 1 ) && ( $_intPort <= 65536 ) ) )
  639. $this->_smtpsPort = $_intPort;
  640. }
  641. /**
  642. * Retrieves the Port Number of the Mail Server to use
  643. * This is used only with 'socket' based mail transmission
  644. *
  645. * @return string Port Number of the Mail Server to use
  646. */
  647. function getPort()
  648. {
  649. return $this->_smtpsPort;
  650. }
  651. /**
  652. * User Name for authentication on Mail Server
  653. *
  654. * @param string $_strID User Name for authentication on Mail Server
  655. * @return void
  656. */
  657. function setID($_strID)
  658. {
  659. $this->_smtpsID = $_strID;
  660. }
  661. /**
  662. * Retrieves the User Name for authentication on Mail Server
  663. *
  664. * @return string User Name for authentication on Mail Server
  665. */
  666. function getID()
  667. {
  668. return $this->_smtpsID;
  669. }
  670. /**
  671. * User Password for authentication on Mail Server
  672. *
  673. * @param string $_strPW User Password for authentication on Mail Server
  674. * @return void
  675. */
  676. function setPW($_strPW)
  677. {
  678. $this->_smtpsPW = $_strPW;
  679. }
  680. /**
  681. * Retrieves the User Password for authentication on Mail Server
  682. *
  683. * @return string User Password for authentication on Mail Server
  684. */
  685. function getPW()
  686. {
  687. return $this->_smtpsPW;
  688. }
  689. /**
  690. * Character set used for current message
  691. * Character set is defaulted to 'iso-8859-1';
  692. *
  693. * @param string $_strCharSet Character set used for current message
  694. * @return void
  695. */
  696. function setCharSet($_strCharSet)
  697. {
  698. if ( $_strCharSet )
  699. $this->_smtpsCharSet = $_strCharSet;
  700. }
  701. /**
  702. * Retrieves the Character set used for current message
  703. *
  704. * @return string $_smtpsCharSet Character set used for current message
  705. */
  706. function getCharSet()
  707. {
  708. return $this->_smtpsCharSet;
  709. }
  710. /**
  711. * Content-Transfer-Encoding, Defaulted to '7bit'
  712. * This can be changed for 2byte characers sets
  713. * Known Encode Types
  714. * - 7bit Simple 7-bit ASCII
  715. * - 8bit 8-bit coding with line termination characters
  716. * - base64 3 octets encoded into 4 sextets with offset
  717. * - binary Arbitrary binary stream
  718. * - mac-binhex40 Macintosh binary to hex encoding
  719. * - quoted-printable Mostly 7-bit, with 8-bit characters encoded as "=HH"
  720. * - uuencode UUENCODE encoding
  721. *
  722. * @param string $_strTransEncode Content-Transfer-Encoding
  723. * @return void
  724. */
  725. function setTransEncode($_strTransEncode)
  726. {
  727. if (array_search($_strTransEncode, $this->_smtpsTransEncodeTypes))
  728. $this->_smtpsTransEncode = $_strTransEncode;
  729. }
  730. /**
  731. * Retrieves the Content-Transfer-Encoding
  732. *
  733. * @return string $_smtpsTransEncode Content-Transfer-Encoding
  734. */
  735. function getTransEncode()
  736. {
  737. return $this->_smtpsTransEncode;
  738. }
  739. /**
  740. * Content-Transfer-Encoding, Defaulted to '0' [ZERO]
  741. * This can be changed for 2byte characers sets
  742. * Known Encode Types
  743. * - [0] 7bit Simple 7-bit ASCII
  744. * - [1] 8bit 8-bit coding with line termination characters
  745. * - [2] base64 3 octets encoded into 4 sextets with offset
  746. * - [3] binary Arbitrary binary stream
  747. * - [4] mac-binhex40 Macintosh binary to hex encoding
  748. * - [5] quoted-printable Mostly 7-bit, with 8-bit characters encoded as "=HH"
  749. * - [6] uuencode UUENCODE encoding
  750. *
  751. * @param string $_strTransEncodeType Content-Transfer-Encoding
  752. * @return void
  753. *
  754. */
  755. function setTransEncodeType($_strTransEncodeType)
  756. {
  757. if (array_search($_strTransEncodeType, $this->_smtpsTransEncodeTypes))
  758. $this->_smtpsTransEncodeType = $_strTransEncodeType;
  759. }
  760. /**
  761. * Retrieves the Content-Transfer-Encoding
  762. *
  763. * @return string Content-Transfer-Encoding
  764. */
  765. function getTransEncodeType()
  766. {
  767. return $this->_smtpsTransEncodeTypes[$this->_smtpsTransEncodeType];
  768. }
  769. // ** Message Construction
  770. /**
  771. * FROM Address from which mail will be sent
  772. *
  773. * @param string $_strFrom Address from which mail will be sent
  774. * @return void
  775. */
  776. function setFrom($_strFrom)
  777. {
  778. if ( $_strFrom )
  779. $this->_msgFrom = $this->_strip_email($_strFrom);
  780. }
  781. /**
  782. * Retrieves the Address from which mail will be sent
  783. *
  784. * @param boolean $_part To "strip" 'Real name' from address
  785. * @return string Address from which mail will be sent
  786. */
  787. function getFrom($_part = true)
  788. {
  789. $_retValue = '';
  790. if ( $_part === true )
  791. $_retValue = $this->_msgFrom;
  792. else
  793. $_retValue = $this->_msgFrom[$_part];
  794. return $_retValue;
  795. }
  796. /**
  797. * Reply-To Address from which mail will be the reply-to
  798. *
  799. * @param string $_strReplyTo Address from which mail will be the reply-to
  800. * @return void
  801. */
  802. function setReplyTo($_strReplyTo)
  803. {
  804. if ( $_strReplyTo )
  805. $this->_msgReplyTo = $this->_strip_email($_strReplyTo);
  806. }
  807. /**
  808. * Retrieves the Address from which mail will be the reply-to
  809. *
  810. * @param boolean $_part To "strip" 'Real name' from address
  811. * @return string Address from which mail will be the reply-to
  812. */
  813. function getReplyTo($_part = true)
  814. {
  815. $_retValue = '';
  816. if ( $_part === true )
  817. $_retValue = $this->_msgReplyTo;
  818. else
  819. $_retValue = $this->_msgReplyTo[$_part];
  820. return $_retValue;
  821. }
  822. /**
  823. * Inserts given addresses into structured format.
  824. * This method takes a list of given addresses, via an array
  825. * or a COMMA delimted string, and inserts them into a highly
  826. * structured array. This array is designed to remove duplicate
  827. * addresses and to sort them by Domain.
  828. *
  829. * @param string $_type TO, CC, or BCC lists to add addrresses into
  830. * @param mixed $_addrList Array or COMMA delimited string of addresses
  831. * @return void
  832. *
  833. */
  834. function _buildAddrList($_type, $_addrList)
  835. {
  836. // Pull existing list
  837. $aryHost = $this->_msgRecipients;
  838. // Only run this if we have something
  839. if ( !empty ($_addrList ))
  840. {
  841. // $_addrList can be a STRING or an array
  842. if ( is_string($_addrList) )
  843. {
  844. // This could be a COMMA delimited string
  845. if ( strstr($_addrList, ',') )
  846. // "explode "list" into an array
  847. $_addrList = explode(',', $_addrList);
  848. // Stick it in an array
  849. else
  850. $_addrList = array($_addrList);
  851. }
  852. // take the array of addresses and split them further
  853. foreach ( $_addrList as $_strAddr )
  854. {
  855. // Strip off the end '>'
  856. $_strAddr = str_replace('>', '', $_strAddr);
  857. // Seperate "Real Name" from eMail address
  858. $_tmpaddr = null;
  859. $_tmpaddr = explode('<', $_strAddr);
  860. // We have a "Real Name" and eMail address
  861. if ( count($_tmpaddr) == 2 )
  862. {
  863. $_tmpHost = explode('@', $_tmpaddr[1]);
  864. $_tmpaddr[0] = trim($_tmpaddr[0], ' ">');
  865. $aryHost[$_tmpHost[1]][$_type][$_tmpHost[0]] = $_tmpaddr[0];
  866. }
  867. // We only have an eMail address
  868. else
  869. {
  870. // Strip off the beggining '<'
  871. $_strAddr = str_replace('<', '', $_strAddr);
  872. $_tmpHost = explode('@', $_strAddr);
  873. $_tmpHost[0] = trim($_tmpHost[0]);
  874. $_tmpHost[1] = trim($_tmpHost[1]);
  875. $aryHost[$_tmpHost[1]][$_type][$_tmpHost[0]] = '';
  876. }
  877. }
  878. }
  879. // replace list
  880. $this->_msgRecipients = $aryHost;
  881. }
  882. /**
  883. * Returns an array of the various parts of an email address
  884. * This assumes a well formed address:
  885. * - "Real name" <username@domain.tld>
  886. * - "Real Name" is optional
  887. * - if "Real Name" does not exist, the angle brackets are optional
  888. * This will split an email address into 4 or 5 parts.
  889. * - $_aryEmail[org] = orignal string
  890. * - $_aryEmail[real] = "real name" - if there is one
  891. * - $_aryEmail[addr] = address part "username@domain.tld"
  892. * - $_aryEmail[host] = "domain.tld"
  893. * - $_aryEmail[user] = "userName"
  894. *
  895. * @param string $_strAddr Email address
  896. * @return array An array of the various parts of an email address
  897. */
  898. function _strip_email($_strAddr)
  899. {
  900. // Keep the orginal
  901. $_aryEmail['org'] = $_strAddr;
  902. // Set entire string to Lower Case
  903. $_strAddr = strtolower($_strAddr);
  904. // Drop "stuff' off the end
  905. $_strAddr = trim($_strAddr, ' ">');
  906. // Seperate "Real Name" from eMail address, if we have one
  907. $_tmpAry = explode('<', $_strAddr);
  908. // Do we have a "Real name"
  909. if ( count($_tmpAry) == 2 )
  910. {
  911. // We may not really have a "Real Name"
  912. if ( $_tmpAry[0])
  913. $_aryEmail['real'] = trim($_tmpAry[0], ' ">');
  914. $_aryEmail['addr'] = $_tmpAry[1];
  915. }
  916. else
  917. $_aryEmail['addr'] = $_tmpAry[0];
  918. // Pull User Name and Host.tld apart
  919. list($_aryEmail['user'], $_aryEmail['host'] ) = explode('@', $_aryEmail['addr']);
  920. // Put the brackets back around the address
  921. $_aryEmail['addr'] = '<' . $_aryEmail['addr'] . '>';
  922. return $_aryEmail;
  923. }
  924. /**
  925. * Returns an array of bares addresses for use with 'RCPT TO:'
  926. * This is a "build as you go" method. Each time this method is called
  927. * the underlaying array is destroyed and reconstructed.
  928. *
  929. * @return array Returns an array of bares addresses
  930. */
  931. function get_RCPT_list()
  932. {
  933. /**
  934. * An array of bares addresses for use with 'RCPT TO:'
  935. */
  936. $_RCPT_list=array();
  937. // walk down Recipients array and pull just email addresses
  938. foreach ( $this->_msgRecipients as $_host => $_list )
  939. {
  940. foreach ( $_list as $_subList )
  941. {
  942. foreach ( $_subList as $_name => $_addr )
  943. {
  944. // build RCPT list
  945. $_RCPT_list[] = $_name . '@' . $_host;
  946. }
  947. }
  948. }
  949. return $_RCPT_list;
  950. }
  951. /**
  952. * Returns an array of addresses for a specific type; TO, CC or BCC
  953. *
  954. * @param string $_which Which collection of addresses to return ('to', 'cc', 'bcc')
  955. * @return string|false Array of emaill address
  956. */
  957. function get_email_list($_which = null)
  958. {
  959. // We need to know which address segment to pull
  960. if ( $_which )
  961. {
  962. // Make sure we have addresses to process
  963. if ( $this->_msgRecipients )
  964. {
  965. $_RCPT_list=array();
  966. // walk down Recipients array and pull just email addresses
  967. foreach ( $this->_msgRecipients as $_host => $_list )
  968. {
  969. if ( $this->_msgRecipients[$_host][$_which] )
  970. {
  971. foreach ( $this->_msgRecipients[$_host][$_which] as $_addr => $_realName )
  972. {
  973. if ( $_realName ) // DOL_CHANGE LDR
  974. {
  975. $_realName = '"' . $_realName . '"';
  976. $_RCPT_list[] = $_realName . ' <' . $_addr . '@' . $_host . '>';
  977. }
  978. else
  979. {
  980. $_RCPT_list[] = $_addr . '@' . $_host;
  981. }
  982. }
  983. }
  984. }
  985. return implode(', ', $_RCPT_list);
  986. }
  987. else
  988. {
  989. $this->_setErr(101, 'No eMail Address for message to be sent to.');
  990. return false;
  991. }
  992. }
  993. else
  994. {
  995. $this->_setErr(102, 'eMail type not defined.');
  996. return false;
  997. }
  998. }
  999. /**
  1000. * TO Address[es] inwhich to send mail to
  1001. *
  1002. * @param string $_addrTo TO Address[es] inwhich to send mail to
  1003. * @return void
  1004. */
  1005. function setTO($_addrTo)
  1006. {
  1007. if ( $_addrTo )
  1008. $this->_buildAddrList('to', $_addrTo);
  1009. }
  1010. /**
  1011. * Retrieves the TO Address[es] inwhich to send mail to
  1012. *
  1013. * @return string TO Address[es] inwhich to send mail to
  1014. */
  1015. function getTo()
  1016. {
  1017. return $this->get_email_list('to');
  1018. }
  1019. /**
  1020. * CC Address[es] inwhich to send mail to
  1021. *
  1022. * @param string $_strCC CC Address[es] inwhich to send mail to
  1023. * @return void
  1024. */
  1025. function setCC($_strCC)
  1026. {
  1027. if ( $_strCC )
  1028. $this->_buildAddrList('cc', $_strCC);
  1029. }
  1030. /**
  1031. * Retrieves the CC Address[es] inwhich to send mail to
  1032. *
  1033. * @return string CC Address[es] inwhich to send mail to
  1034. */
  1035. function getCC()
  1036. {
  1037. return $this->get_email_list('cc');
  1038. }
  1039. /**
  1040. * BCC Address[es] inwhich to send mail to
  1041. *
  1042. * @param string $_strBCC Recipients BCC Address[es] inwhich to send mail to
  1043. * @return void
  1044. */
  1045. function setBCC($_strBCC)
  1046. {
  1047. if ( $_strBCC )
  1048. $this->_buildAddrList('bcc', $_strBCC);
  1049. }
  1050. /**
  1051. * Retrieves the BCC Address[es] inwhich to send mail to
  1052. *
  1053. * @return string BCC Address[es] inwhich to send mail to
  1054. */
  1055. function getBCC()
  1056. {
  1057. return $this->get_email_list('bcc');
  1058. }
  1059. /**
  1060. * Message Subject
  1061. *
  1062. * @param string $_strSubject Message Subject
  1063. * @return void
  1064. */
  1065. function setSubject($_strSubject = '')
  1066. {
  1067. if ( $_strSubject )
  1068. $this->_msgSubject = $_strSubject;
  1069. }
  1070. /**
  1071. * Retrieves the Message Subject
  1072. *
  1073. * @return string Message Subject
  1074. */
  1075. function getSubject()
  1076. {
  1077. return $this->_msgSubject;
  1078. }
  1079. /**
  1080. * Constructes and returns message header
  1081. *
  1082. * @return string Complete message header
  1083. */
  1084. function getHeader()
  1085. {
  1086. $_header = 'From: ' . $this->getFrom('org') . "\r\n"
  1087. . 'To: ' . $this->getTO() . "\r\n";
  1088. if ( $this->getCC() )
  1089. $_header .= 'Cc: ' . $this->getCC() . "\r\n";
  1090. /* Note:
  1091. * BCC email addresses must be listed in the RCPT TO command list,
  1092. * but the BCC header should not be printed under the DATA command.
  1093. * So it is included into the function sendMsg() but not here.
  1094. * http://stackoverflow.com/questions/2750211/sending-bcc-emails-using-a-smtp-server
  1095. */
  1096. /*
  1097. if ( $this->getBCC() )
  1098. $_header .= 'Bcc: ' . $this->getBCC() . "\r\n";
  1099. */
  1100. $host=$this->getHost();
  1101. $host=preg_replace('@tcp://@i','',$host); // Remove prefix
  1102. $host=preg_replace('@ssl://@i','',$host); // Remove prefix
  1103. $host=dol_getprefix('email');
  1104. //NOTE: Message-ID should probably contain the username of the user who sent the msg
  1105. $_header .= 'Subject: ' . $this->getSubject() . "\r\n";
  1106. $_header .= 'Date: ' . date("r") . "\r\n";
  1107. $trackid = $this->getTrackId();
  1108. if ($trackid)
  1109. {
  1110. // References is kept in response and Message-ID is returned into In-Reply-To:
  1111. $_header .= 'Message-ID: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n";
  1112. $_header .= 'References: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n";
  1113. $_header .= 'X-Dolibarr-TRACKID: ' . $trackid . "\r\n";
  1114. }
  1115. else
  1116. {
  1117. $_header .= 'Message-ID: <' . time() . '.SMTPs@' . $host . ">\r\n";
  1118. }
  1119. if ( $this->getMoreInHeader() )
  1120. $_header .= $this->getMoreInHeader(); // Value must include the "\r\n";
  1121. //$_header .=
  1122. // 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"
  1123. // 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n";
  1124. if ( $this->getSensitivity() )
  1125. $_header .= 'Sensitivity: ' . $this->getSensitivity() . "\r\n";
  1126. if ( $this->_msgPriority != 3 )
  1127. $_header .= $this->getPriority();
  1128. // DOL_CHANGE LDR
  1129. if ( $this->getDeliveryReceipt() )
  1130. $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n";
  1131. if ( $this->getErrorsTo() )
  1132. $_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n";
  1133. if ( $this->getReplyTo() )
  1134. $_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n";
  1135. $_header .= 'X-Mailer: Dolibarr version ' . DOL_VERSION .' (using SMTPs Mailer)' . "\r\n";
  1136. $_header .= 'Mime-Version: 1.0' . "\r\n";
  1137. return $_header;
  1138. }
  1139. /**
  1140. * Message Content
  1141. *
  1142. * @param string $strContent Message Content
  1143. * @param string $strType Type
  1144. * @return void
  1145. */
  1146. function setBodyContent($strContent, $strType = 'plain')
  1147. {
  1148. //if ( $strContent )
  1149. //{
  1150. if ( $strType == 'html' )
  1151. $strMimeType = 'text/html';
  1152. else
  1153. $strMimeType = 'text/plain';
  1154. // Make RFC821 Compliant, replace bare linefeeds
  1155. $strContent = preg_replace("/(?<!\r)\n/si", "\r\n", $strContent);
  1156. $strContentAltText = '';
  1157. if ($strType == 'html')
  1158. {
  1159. $strContentAltText = html_entity_decode(strip_tags($strContent));
  1160. $strContentAltText = rtrim(wordwrap($strContentAltText, 75, "\r\n"));
  1161. }
  1162. // Make RFC2045 Compliant
  1163. //$strContent = rtrim(chunk_split($strContent)); // Function chunck_split seems ko if not used on a base64 content
  1164. $strContent = rtrim(wordwrap($strContent, 75, "\r\n")); // TODO Using this method creates unexpected line break on text/plain content.
  1165. $this->_msgContent[$strType] = array();
  1166. $this->_msgContent[$strType]['mimeType'] = $strMimeType;
  1167. $this->_msgContent[$strType]['data'] = $strContent;
  1168. $this->_msgContent[$strType]['dataText'] = $strContentAltText;
  1169. if ( $this->getMD5flag() )
  1170. $this->_msgContent[$strType]['md5'] = dol_hash($strContent, 3);
  1171. //}
  1172. }
  1173. /**
  1174. * Retrieves the Message Content
  1175. *
  1176. * @return string Message Content
  1177. */
  1178. function getBodyContent()
  1179. {
  1180. global $conf;
  1181. // Generate a new Boundary string
  1182. $this->_setBoundary();
  1183. // What type[s] of content do we have
  1184. $_types = array_keys($this->_msgContent);
  1185. // How many content types do we have
  1186. $keyCount = count($_types);
  1187. // If we have ZERO, we have a problem
  1188. if( $keyCount === 0 )
  1189. die ("Sorry, no content");
  1190. // If we have ONE, we can use the simple format
  1191. else if( $keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART))
  1192. {
  1193. $_msgData = $this->_msgContent;
  1194. $_msgData = $_msgData[$_types[0]];
  1195. $content = 'Content-Type: ' . $_msgData['mimeType'] . '; charset="' . $this->getCharSet() . '"' . "\r\n"
  1196. . 'Content-Transfer-Encoding: ' . $this->getTransEncodeType() . "\r\n"
  1197. . 'Content-Disposition: inline' . "\r\n"
  1198. . 'Content-Description: message' . "\r\n";
  1199. if ( $this->getMD5flag() )
  1200. $content .= 'Content-MD5: ' . $_msgData['md5'] . "\r\n";
  1201. $content .= "\r\n"
  1202. . $_msgData['data'] . "\r\n";
  1203. }
  1204. // If we have more than ONE, we use the multi-part format
  1205. else if( $keyCount >= 1 || ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART))
  1206. {
  1207. // Since this is an actual multi-part message
  1208. // We need to define a content message Boundary
  1209. // NOTE: This was 'multipart/alternative', but Windows based mail servers have issues with this.
  1210. //$content = 'Content-Type: multipart/related; boundary="' . $this->_getBoundary() . '"' . "\r\n";
  1211. $content = 'Content-Type: multipart/mixed; boundary="' . $this->_getBoundary('mixed') . '"' . "\r\n";
  1212. // . "\r\n"
  1213. // . 'This is a multi-part message in MIME format.' . "\r\n";
  1214. $content .= "Content-Transfer-Encoding: 8bit\r\n";
  1215. $content .= "\r\n";
  1216. $content .= "--" . $this->_getBoundary('mixed') . "\r\n";
  1217. if (key_exists('image', $this->_msgContent)) // If inline image found
  1218. {
  1219. $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n";
  1220. $content .= "\r\n";
  1221. $content .= "--" . $this->_getBoundary('alternative') . "\r\n";
  1222. }
  1223. // $this->_msgContent must be sorted with key 'text' or 'html' first then 'image' then 'attachment'
  1224. // Loop through message content array
  1225. foreach ($this->_msgContent as $type => $_content )
  1226. {
  1227. if ( $type == 'attachment' )
  1228. {
  1229. // loop through all attachments
  1230. foreach ( $_content as $_file => $_data )
  1231. {
  1232. $content .= "--" . $this->_getBoundary('mixed') . "\r\n"
  1233. . 'Content-Disposition: attachment; filename="' . $_data['fileName'] . '"' . "\r\n"
  1234. . 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['fileName'] . '"' . "\r\n"
  1235. . 'Content-Transfer-Encoding: base64' . "\r\n"
  1236. . 'Content-Description: File Attachment' . "\r\n";
  1237. if ( $this->getMD5flag() )
  1238. $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n";
  1239. $content .= "\r\n" . $_data['data'] . "\r\n\r\n";
  1240. }
  1241. }
  1242. // DOL_CHANGE LDR
  1243. else if ( $type == 'image' )
  1244. {
  1245. // loop through all images
  1246. foreach ( $_content as $_image => $_data )
  1247. {
  1248. $content .= "--" . $this->_getBoundary('related') . "\r\n"; // always related for an inline image
  1249. $content .= 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['imageName'] . '"' . "\r\n"
  1250. . 'Content-Transfer-Encoding: base64' . "\r\n"
  1251. . 'Content-Disposition: inline; filename="' . $_data['imageName'] . '"' . "\r\n"
  1252. . 'Content-ID: <' . $_data['cid'] . '> ' . "\r\n";
  1253. if ( $this->getMD5flag() )
  1254. $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n";
  1255. $content .= "\r\n"
  1256. . $_data['data'] . "\r\n";
  1257. }
  1258. // always end related and end alternative after inline images
  1259. $content.= "--" . $this->_getBoundary('related') . "--" . "\r\n";
  1260. $content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n";
  1261. $content.= "\r\n";
  1262. }
  1263. else
  1264. {
  1265. if (key_exists('image', $this->_msgContent))
  1266. {
  1267. $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n";
  1268. $content.= "\r\n" . ($_content['dataText']?$_content['dataText']:strip_tags($_content['data'])) . "\r\n"; // Add plain text message
  1269. $content.= "--" . $this->_getBoundary('alternative') . "\r\n";
  1270. $content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n";
  1271. $content.= "\r\n";
  1272. $content.= "--" . $this->_getBoundary('related') . "\r\n";
  1273. }
  1274. if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part
  1275. {
  1276. $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n";
  1277. $content .= "\r\n";
  1278. $content .= "--" . $this->_getBoundary('alternative') . "\r\n";
  1279. $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n";
  1280. $content.= "\r\n". $_content['dataText'] . "\r\n";
  1281. $content.= "--" . $this->_getBoundary('alternative') . "\r\n";
  1282. }
  1283. $content .= 'Content-Type: ' . $_content['mimeType'] . '; '
  1284. // . 'charset="' . $this->getCharSet() . '"';
  1285. . 'charset=' . $this->getCharSet() . '';
  1286. // $content .= ( $type == 'html') ? '; name="HTML Part"' : '';
  1287. $content .= "\r\n";
  1288. // $content .= 'Content-Transfer-Encoding: ';
  1289. // $content .= ($type == 'html') ? 'quoted-printable' : $this->getTransEncodeType();
  1290. // $content .= "\r\n"
  1291. // . 'Content-Disposition: inline' . "\r\n"
  1292. // . 'Content-Description: ' . $type . ' message' . "\r\n";
  1293. if ( $this->getMD5flag() )
  1294. $content .= 'Content-MD5: ' . $_content['md5'] . "\r\n";
  1295. $content .= "\r\n" . $_content['data'] . "\r\n";
  1296. if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part after html part
  1297. {
  1298. $content.= "--" . $this->_getBoundary('alternative') . "--". "\r\n";
  1299. }
  1300. $content .= "\r\n";
  1301. }
  1302. }
  1303. // Close message boundries
  1304. // $content .= "\r\n--" . $this->_getBoundary() . '--' . "\r\n" ;
  1305. $content .= "--" . $this->_getBoundary('mixed') . '--' . "\r\n" ;
  1306. }
  1307. return $content;
  1308. }
  1309. /**
  1310. * File attachments are added to the content array as sub-arrays,
  1311. * allowing for multiple attachments for each outbound email
  1312. *
  1313. * @param string $strContent File data to attach to message
  1314. * @param string $strFileName File Name to give to attachment
  1315. * @param string $strMimeType File Mime Type of attachment
  1316. * @return void
  1317. */
  1318. function setAttachment($strContent, $strFileName = 'unknown', $strMimeType = 'unknown')
  1319. {
  1320. if ( $strContent )
  1321. {
  1322. $strContent = rtrim(chunk_split(base64_encode($strContent), 76, "\r\n")); // 76 max is defined into http://tools.ietf.org/html/rfc2047
  1323. $this->_msgContent['attachment'][$strFileName]['mimeType'] = $strMimeType;
  1324. $this->_msgContent['attachment'][$strFileName]['fileName'] = $strFileName;
  1325. $this->_msgContent['attachment'][$strFileName]['data'] = $strContent;
  1326. if ( $this->getMD5flag() )
  1327. $this->_msgContent['attachment'][$strFileName]['md5'] = dol_hash($strContent, 3);
  1328. }
  1329. }
  1330. // DOL_CHANGE LDR
  1331. /**
  1332. * Image attachments are added to the content array as sub-arrays,
  1333. * allowing for multiple images for each outbound email
  1334. *
  1335. * @param string $strContent Image data to attach to message
  1336. * @param string $strImageName Image Name to give to attachment
  1337. * @param string $strMimeType Image Mime Type of attachment
  1338. * @param string $strImageCid CID
  1339. * @return void
  1340. */
  1341. function setImageInline($strContent, $strImageName = 'unknown', $strMimeType = 'unknown', $strImageCid = 'unknown')
  1342. {
  1343. if ($strContent)
  1344. {
  1345. $this->_msgContent['image'][$strImageName]['mimeType'] = $strMimeType;
  1346. $this->_msgContent['image'][$strImageName]['imageName'] = $strImageName;
  1347. $this->_msgContent['image'][$strImageName]['cid'] = $strImageCid;
  1348. $this->_msgContent['image'][$strImageName]['data'] = $strContent;
  1349. if ( $this->getMD5flag() )
  1350. $this->_msgContent['image'][$strImageName]['md5'] = dol_hash($strContent, 3);
  1351. }
  1352. }
  1353. // END DOL_CHANGE LDR
  1354. /**
  1355. * Message Content Sensitivity
  1356. * Message Sensitivity values:
  1357. * - [0] None - default
  1358. * - [1] Personal
  1359. * - [2] Private
  1360. * - [3] Company Confidential
  1361. *
  1362. * @param integer $_value Message Sensitivity
  1363. * @return void
  1364. */
  1365. function setSensitivity($_value = 0)
  1366. {
  1367. if ( ( is_numeric($_value) ) &&
  1368. ( ( $_value >= 0 ) && ( $_value <= 3 ) ) )
  1369. $this->_msgSensitivity = $_value;
  1370. }
  1371. /**
  1372. * Returns Message Content Sensitivity string
  1373. * Message Sensitivity values:
  1374. * - [0] None - default
  1375. * - [1] Personal
  1376. * - [2] Private
  1377. * - [3] Company Confidential
  1378. *
  1379. * @return void
  1380. */
  1381. function getSensitivity()
  1382. {
  1383. return $this->_arySensitivity[$this->_msgSensitivity];
  1384. }
  1385. /**
  1386. * Message Content Priority
  1387. * Message Priority values:
  1388. * - [0] 'Bulk'
  1389. * - [1] 'Highest'
  1390. * - [2] 'High'
  1391. * - [3] 'Normal' - default
  1392. * - [4] 'Low'
  1393. * - [5] 'Lowest'
  1394. *
  1395. * @param integer $_value Message Priority
  1396. * @return void
  1397. */
  1398. function setPriority ( $_value = 3 )
  1399. {
  1400. if ( ( is_numeric($_value) ) &&
  1401. ( ( $_value >= 0 ) && ( $_value <= 5 ) ) )
  1402. $this->_msgPriority = $_value;
  1403. }
  1404. /**
  1405. * Message Content Priority
  1406. * Message Priority values:
  1407. * - [0] 'Bulk'
  1408. * - [1] 'Highest'
  1409. * - [2] 'High'
  1410. * - [3] 'Normal' - default
  1411. * - [4] 'Low'
  1412. * - [5] 'Lowest'
  1413. *
  1414. * @return string
  1415. */
  1416. function getPriority()
  1417. {
  1418. return 'Importance: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n"
  1419. . 'Priority: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n"
  1420. . 'X-Priority: ' . $this->_msgPriority . ' (' . $this->_aryPriority[$this->_msgPriority] . ')' . "\r\n";
  1421. }
  1422. /**
  1423. * Set flag which determines whether to calculate message MD5 checksum.
  1424. *
  1425. * @param string $_flag Message Priority
  1426. * @return void
  1427. */
  1428. function setMD5flag($_flag = false)
  1429. {
  1430. $this->_smtpMD5 = $_flag;
  1431. }
  1432. /**
  1433. * Gets flag which determines whether to calculate message MD5 checksum.
  1434. *
  1435. * @return boolean Message Priority
  1436. */
  1437. function getMD5flag()
  1438. {
  1439. return $this->_smtpMD5;
  1440. }
  1441. /**
  1442. * Message X-Header Content
  1443. * This is a simple "insert". Whatever is given will be placed
  1444. * "as is" into the Xheader array.
  1445. *
  1446. * @param string $strXdata Message X-Header Content
  1447. * @return void
  1448. */
  1449. function setXheader($strXdata)
  1450. {
  1451. if ( $strXdata )
  1452. $this->_msgXheader[] = $strXdata;
  1453. }
  1454. /**
  1455. * Retrieves the Message X-Header Content
  1456. *
  1457. * @return string[] $_msgContent Message X-Header Content
  1458. */
  1459. function getXheader()
  1460. {
  1461. return $this->_msgXheader;
  1462. }
  1463. /**
  1464. * Generates Random string for MIME message Boundary
  1465. *
  1466. * @return void
  1467. */
  1468. function _setBoundary()
  1469. {
  1470. $this->_smtpsBoundary = "multipart_x." . time() . ".x_boundary";
  1471. $this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2"), 3);
  1472. $this->_smtpsAlternativeBoundary = 'mul_'.dol_hash(uniqid("dolibarr3"), 3);
  1473. }
  1474. /**
  1475. * Retrieves the MIME message Boundary
  1476. *
  1477. * @param string $type Type of boundary
  1478. * @return string $_smtpsBoundary MIME message Boundary
  1479. */
  1480. function _getBoundary($type='mixed')
  1481. {
  1482. if ($type == 'mixed') return $this->_smtpsBoundary;
  1483. else if ($type == 'related') return $this->_smtpsRelatedBoundary;
  1484. else if ($type == 'alternative') return $this->_smtpsAlternativeBoundary;
  1485. }
  1486. /**
  1487. * This function has been modified as provided by SirSir to allow multiline responses when
  1488. * using SMTP Extensions
  1489. *
  1490. * @param Handler $socket Socket handler
  1491. * @param string $response Response
  1492. * @return boolean True or false
  1493. */
  1494. function server_parse($socket, $response)
  1495. {
  1496. /**
  1497. * Returns constructed SELECT Object string or boolean upon failure
  1498. * Default value is set at TRUE
  1499. */
  1500. $_retVal = true;
  1501. $server_response = '';
  1502. // avoid infinite loop
  1503. $limit=0;
  1504. while ( substr($server_response,3,1) != ' ' && $limit<100)
  1505. {
  1506. if( !( $server_response = fgets($socket, 256) ) )
  1507. {
  1508. $this->_setErr(121, "Couldn't get mail server response codes");
  1509. $_retVal = false;
  1510. }
  1511. $limit++;
  1512. }
  1513. if( !( substr($server_response, 0, 3) == $response ) )
  1514. {
  1515. $this->_setErr(120, "Ran into problems sending Mail.\r\nResponse: $server_response");
  1516. $_retVal = false;
  1517. }
  1518. return $_retVal;
  1519. }
  1520. /**
  1521. * Send str
  1522. *
  1523. * @param string $_strSend String to send
  1524. * @param string $_returnCode Return code
  1525. * @param string $CRLF CRLF
  1526. * @return boolean|null True or false
  1527. */
  1528. function socket_send_str( $_strSend, $_returnCode = null, $CRLF = "\r\n" )
  1529. {
  1530. if ($this->_debug) $this->log.=$_strSend; // DOL_CHANGE LDR for log
  1531. fputs($this->socket, $_strSend . $CRLF);
  1532. if ($this->_debug) $this->log.=' ('.$_returnCode.')' . $CRLF;
  1533. if ( $_returnCode )
  1534. return $this->server_parse($this->socket, $_returnCode);
  1535. }
  1536. // =============================================================
  1537. // ** Error handling methods
  1538. /**
  1539. * Defines errors codes and messages for Class
  1540. *
  1541. * @param int $_errNum Error Code Number
  1542. * @param string $_errMsg Error Message
  1543. * @return void
  1544. */
  1545. function _setErr ( $_errNum, $_errMsg )
  1546. {
  1547. $this->_smtpsErrors[] = array( 'num' => $_errNum,
  1548. 'msg' => $_errMsg );
  1549. }
  1550. /**
  1551. * Returns errors codes and messages for Class
  1552. *
  1553. * @return string $_errMsg Error Message
  1554. */
  1555. function getErrors()
  1556. {
  1557. $_errMsg = array();
  1558. foreach ( $this->_smtpsErrors as $_err => $_info )
  1559. {
  1560. $_errMsg[] = 'Error [' . $_info['num'] .']: '. $_info['msg'];
  1561. }
  1562. return implode("\n", $_errMsg);
  1563. }
  1564. }
  1565. // =============================================================
  1566. // ** CSV Version Control Info
  1567. /**
  1568. * Revision 2011/09/12 07:49:59 eldy
  1569. * Doxygen
  1570. *
  1571. * Revision 2011/09/06 06:53:53 hregis
  1572. * Fix: use dol_hash instead md5 php function
  1573. *
  1574. * Revision 2011/09/03 00:14:27 eldy
  1575. * Doxygen
  1576. *
  1577. * Revision 2011/08/28 14:24:23 eldy
  1578. * Doxygen
  1579. *
  1580. * Revision 2011/07/12 22:19:02 eldy
  1581. * Fix: Attachment fails if content was empty
  1582. *
  1583. * Revision 2011/06/20 23:17:50 hregis
  1584. * Fix: use best structure of mail
  1585. *
  1586. * Revision 2010/04/13 20:58:37 eldy
  1587. * Fix: Can provide ip address on smtps. Better error reporting.
  1588. *
  1589. * Revision 2010/04/13 20:30:25 eldy
  1590. * Fix: Can provide ip address on smtps. Better error reporting.
  1591. *
  1592. * Revision 2010/01/12 13:02:07 hregis
  1593. * Fix: missing attach-files
  1594. *
  1595. * Revision 2009/11/01 14:16:30 eldy
  1596. * Fix: Sending mail with SMTPS was not working.
  1597. *
  1598. * Revision 2009/10/20 13:14:47 hregis
  1599. * Fix: function "split" is deprecated since php 5.3.0
  1600. *
  1601. * Revision 2009/05/13 19:10:07 eldy
  1602. * New: Can use inline images.Everything seems to work with thunderbird and webmail gmail. New to be tested on other mail browsers.
  1603. *
  1604. * Revision 2009/05/13 14:49:30 eldy
  1605. * Fix: Make code so much simpler and solve a lot of problem with new version.
  1606. *
  1607. * Revision 2009/02/09 00:04:35 eldy
  1608. * Added support for SMTPS protocol
  1609. *
  1610. * Revision 2008/04/16 23:11:45 eldy
  1611. * New: Add action "Test server connectivity"
  1612. *
  1613. * Revision 1.18 2007/01/12 22:17:08 ongardie
  1614. * - Added full_http_site_root() to utils-misc.php
  1615. * - Made SMTPs' getError() easier to use
  1616. * - Improved activity modified emails
  1617. *
  1618. * Revision 1.17 2006/04/05 03:15:40 ongardie
  1619. * -Fixed method name typo that resulted in a fatal error.
  1620. *
  1621. * Revision 1.16 2006/03/08 04:05:25 jswalter
  1622. * - '$_smtpsTransEncode' was removed and '$_smtpsTransEncodeType' is now used
  1623. * - '$_smtpsTransEncodeType' is defaulted to ZERO
  1624. * - corrected 'setCharSet()' internal vars
  1625. * - defined '$_mailPath'
  1626. * - added '$_smtpMD5' as a class property
  1627. * - added 'setMD5flag()' to set above property
  1628. * - added 'getMD5flag()' to retrieve above property
  1629. * - 'setAttachment()' will add an MD5 checksum to attachements if above property is set
  1630. * - 'setBodyContent()' will add an MD5 checksum to message parts if above property is set
  1631. * - 'getBodyContent()' will insert the MD5 checksum for messages and attachments if above property is set
  1632. * - removed leading dashes from message boundry
  1633. * - added propery "Close message boundry" tomessage block
  1634. * - corrected some comments in various places
  1635. * - removed some incorrect comments in others
  1636. *
  1637. * Revision 1.15 2006/02/21 02:00:07 vanmer
  1638. * - patch to add support for sending to exim mail server
  1639. * - thanks to Diego Ongaro at ETSZONE (diego@etszone.com)
  1640. *
  1641. * Revision 1.14 2005/08/29 16:22:10 jswalter
  1642. * - change 'multipart/alternative' to 'multipart/mixed', but Windows based mail servers have issues with this.
  1643. * Bug 594
  1644. *
  1645. * Revision 1.13 2005/08/21 01:57:30 vanmer
  1646. * - added initialization for array if no recipients exist
  1647. *
  1648. * Revision 1.12 2005/08/20 12:04:30 braverock
  1649. * - remove potentially binary characters from Message-ID
  1650. * - add getHost to get the hostname of the mailserver
  1651. * - add username to Message-ID header
  1652. *
  1653. * Revision 1.11 2005/08/20 11:49:48 braverock
  1654. * - fix typos in boundary
  1655. * - remove potentially illegal characters from boundary
  1656. *
  1657. * Revision 1.10 2005/08/19 20:39:32 jswalter
  1658. * - added _server_connect()' as a seperate method to handle server connectivity.
  1659. * - added '_server_authenticate()' as a seperate method to handle server authentication.
  1660. * - 'sendMsg()' now uses the new methods to handle server communication.
  1661. * - modified 'server_parse()' and 'socket_send_str()' to give error codes and messages.
  1662. *
  1663. * Revision 1.9 2005/08/19 15:40:18 jswalter
  1664. * - IMPORTANT: 'setAttachement()' is now spelled correctly: 'setAttachment()'
  1665. * - added additional comment to several methods
  1666. * - added '$_smtpsTransEncodeTypes' array to limit encode types
  1667. * - added parameters to 'sendMsg()' for future development around debugging and logging
  1668. * - added error code within 'setConfig()' if the given path is not found
  1669. * - 'setTransportType()' now has parameter validation
  1670. * [this still is not implemented]
  1671. * - 'setPort()' now does parameter validation
  1672. * - 'setTransEncode()' now has parameter validation against '$_smtpsTransEncodeTypes'
  1673. * - modified 'get_email_list()' to handle error handling
  1674. * - 'setSensitivity()' now has parameter validation
  1675. * - 'setPriority()' now has parameter validation
  1676. *
  1677. * Revision 1.8 2005/06/24 21:00:20 jswalter
  1678. * - corrected comments
  1679. * - corrected the defualt value for 'setPriority()'
  1680. * - modified 'setAttachement()' to process multiple attachments correctly
  1681. * - modified 'getBodyContent()' to handle multiple attachments
  1682. * Bug 310
  1683. *
  1684. * Revision 1.7 2005/05/19 21:12:34 braverock
  1685. * - replace chunk_split() with wordwrap() to fix funky wrapping of templates
  1686. *
  1687. * Revision 1.6 2005/04/25 04:55:06 jswalter
  1688. * - cloned from Master Version
  1689. *
  1690. * Revision 1.10 2005/04/25 04:54:10 walter
  1691. * - "fixed" 'getBodyContent()' to handle a "simple" text only message
  1692. *
  1693. * Revision 1.9 2005/04/25 03:52:01 walter
  1694. * - replace closing curly bracket. Removed it in last revision!
  1695. *
  1696. * Revision 1.8 2005/04/25 02:29:49 walter
  1697. * - added '$_transportType' and its getter/setter methods.
  1698. * for future use. NOT yet implemented.
  1699. * - in 'sendMsg()', added HOST validation check
  1700. * - added error check for initial Socket Connection
  1701. * - created new method 'socket_send_str()' to process socket
  1702. * communication in a unified means. Socket calls within
  1703. * 'sendMsg()' have been modified to use this new method.
  1704. * - expanded comments in 'setConfig()'
  1705. * - added "error" check on PHP ini file properties. If these
  1706. * properties not set within the INI file, the default values
  1707. * will be used.
  1708. * - modified 'get_RCPT_list()' to reset itself each time it is called
  1709. * - modified 'setBodyContent()' to store data in a sub-array for better
  1710. * parsing within the 'getBodyContent()' method
  1711. * - modified 'getBodyContent()' to process contents array better.
  1712. * Also modified to handle attachements.
  1713. * - added 'setAttachement()' so files and other data can be attached
  1714. * to messages
  1715. * - added '_setErr()' and 'getErrors()' as an attempt to begin an error
  1716. * handling process within this class
  1717. *
  1718. * Revision 1.7 2005/04/13 15:23:50 walter
  1719. * - made 'CC' a conditional insert
  1720. * - made 'BCC' a conditional insert
  1721. * - fixed 'Message-ID'
  1722. * - corrected 'getSensitivity()'
  1723. * - modified '$_aryPriority[]' to proper values
  1724. * - updated 'setConfig()' to handle external Ini or 'php.ini'
  1725. *
  1726. * Revision 1.6 2005/03/15 17:34:06 walter
  1727. * - corrected Message Sensitivity property and method comments
  1728. * - added array to Message Sensitivity
  1729. * - added getSensitivity() method to use new Sensitivity array
  1730. * - created seters and getter for Priority with new Prioity value array property
  1731. * - changed config file include from 'include_once'
  1732. * - modified getHeader() to ustilize new Message Sensitivity and Priorty properties
  1733. *
  1734. * Revision 1.5 2005/03/14 22:25:27 walter
  1735. * - added references
  1736. * - added Message sensitivity as a property with Getter/Setter methods
  1737. * - boundary is now a property with Getter/Setter methods
  1738. * - added 'builtRCPTlist()'
  1739. * - 'sendMsg()' now uses Object properties and methods to build message
  1740. * - 'setConfig()' to load external file
  1741. * - 'setForm()' will "strip" the email address out of "address" string
  1742. * - modifed 'getFrom()' to handle "striping" the email address
  1743. * - '_buildArrayList()' creates a multi-dimensional array of addresses
  1744. * by domain, TO, CC & BCC and then by User Name.
  1745. * - '_strip_email()' pulls email address out of "full Address" string'
  1746. * - 'get_RCPT_list()' pulls out "bare" emaill address form address array
  1747. * - 'getHeader()' builds message Header from Object properties
  1748. * - 'getBodyContent()' builds full messsage body, even multi-part
  1749. *
  1750. * Revision 1.4 2005/03/02 20:53:35 walter
  1751. * - core Setters & Getters defined
  1752. * - added additional Class Properties
  1753. *
  1754. * Revision 1.3 2005/03/02 18:51:51 walter
  1755. * - added base 'Class Properties'
  1756. *
  1757. * Revision 1.2 2005/03/01 19:37:52 walter
  1758. * - CVS logging tags
  1759. * - more comments
  1760. * - more "shell"
  1761. * - some constants
  1762. *
  1763. * Revision 1.1 2005/03/01 19:22:49 walter
  1764. * - initial commit
  1765. * - basic shell with some commets
  1766. *
  1767. */