dolibarr  9.0.0
smtps.class.php
Go to the documentation of this file.
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 
46 class SMTPs
47 {
51  var $_smtpsHost = 'localhost';
52 
57  var $_smtpsPort = '25';
58 
63  var $_smtpsID = null;
64 
69  var $_smtpsPW = null;
70 
75  var $_msgFrom = null;
76 
81  var $_msgReplyTo = null;
82 
88  var $_msgRecipients = null;
89 
93  var $_msgSubject = null;
94 
98  var $_msgContent = null;
99 
103  var $_msgXheader = null;
104 
109  var $_smtpsCharSet = 'iso-8859-1';
110 
116 
120  var $_arySensitivity = array ( false,
121  'Personal',
122  'Private',
123  'Company Confidential' );
124 
129  var $_msgPriority = 3;
130 
134  var $_aryPriority = array ( 'Bulk',
135  'Highest',
136  'High',
137  'Normal',
138  'Low',
139  'Lowest' );
140 
146 
150  var $_smtpsTransEncodeTypes = array( '7bit', // Simple 7-bit ASCII
151  '8bit', // 8-bit coding with line termination characters
152  'base64', // 3 octets encoded into 4 sextets with offset
153  'binary', // Arbitrary binary stream
154  'mac-binhex40', // Macintosh binary to hex encoding
155  'quoted-printable', // Mostly 7-bit, with 8-bit characters encoded as "=HH"
156  'uuencode' ); // UUENCODE encoding
157 
162  var $_smtpsTransEncode = '7bit';
163 
167  var $_smtpsBoundary = null;
168 
173 
178 
187 
192  var $_mailPath = '/usr/lib/sendmail';
193 
197  var $_smtpTimeout = 10;
198 
202  var $_smtpMD5 = false;
203 
207  var $_smtpsErrors = null;
208 
216  var $_log_level = 0;
217 
221  var $_debug = false;
222 
223 
224  // @CHANGE LDR
225  var $log = '';
226  var $_errorsTo = '';
227  var $_deliveryReceipt = 0;
228  var $_trackId = '';
229  var $_moreInHeader = '';
230 
231 
238  function setDeliveryReceipt($_val = 0)
239  {
240  $this->_deliveryReceipt = $_val;
241  }
242 
249  {
250  return $this->_deliveryReceipt;
251  }
252 
259  function setTrackId($_val = '')
260  {
261  $this->_trackId = $_val;
262  }
263 
270  function setMoreInHeader($_val = '')
271  {
272  $this->_moreinheader = $_val;
273  }
274 
280  function getTrackId()
281  {
282  return $this->_trackId;
283  }
284 
290  function getMoreInHeader()
291  {
292  return $this->_moreinheader;
293  }
294 
301  function setErrorsTo($_strErrorsTo)
302  {
303  if ( $_strErrorsTo )
304  $this->_errorsTo = $this->_strip_email($_strErrorsTo);
305  }
306 
313  function getErrorsTo($_part = true )
314  {
315  $_retValue = '';
316 
317  if ( $_part === true )
318  $_retValue = $this->_errorsTo;
319  else
320  $_retValue = $this->_errorsTo[$_part];
321 
322  return $_retValue;
323  }
324 
331  function setDebug($_vDebug = false )
332  {
333  $this->_debug = $_vDebug;
334  }
335 
341  function buildRCPTlist()
342  {
343  // Pull TO list
344  $_aryToList = $this->getTO();
345  }
346 
347  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
353  function _server_connect()
354  {
355  // phpcs:enable
356  // Default return value
357  $_retVal = true;
358 
359  // We have to make sure the HOST given is valid
360  // This is done here because '@fsockopen' will not give me this
361  // information if it failes to connect because it can't find the HOST
362  $host=$this->getHost();
363  $usetls = preg_match('@tls://@i',$host);
364 
365  $host=preg_replace('@tcp://@i','',$host); // Remove prefix
366  $host=preg_replace('@ssl://@i','',$host); // Remove prefix
367  $host=preg_replace('@tls://@i','',$host); // Remove prefix
368 
369  // @CHANGE LDR
370  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
371 
372  if ( (! is_ip($host)) && ((gethostbyname($host)) == $host))
373  {
374  $this->_setErr(99, $host . ' is either offline or is an invalid host name.');
375  $_retVal = false;
376  }
377  else
378  {
379  //See if we can connect to the SMTP server
380  if ($this->socket = @fsockopen(
381  preg_replace('@tls://@i','',$this->getHost()), // Host to 'hit', IP or domain
382  $this->getPort(), // which Port number to use
383  $this->errno, // actual system level error
384  $this->errstr, // and any text that goes with the error
385  $this->_smtpTimeout
386  )) // timeout for reading/writing data over the socket
387  {
388  // Fix from PHP SMTP class by 'Chris Ryan'
389  // Sometimes the SMTP server takes a little longer to respond
390  // so we will give it a longer timeout for the first read
391  // Windows still does not have support for this timeout function
392  if (function_exists('stream_set_timeout')) stream_set_timeout($this->socket, $this->_smtpTimeout, 0);
393 
394  // Check response from Server
395  if ( $_retVal = $this->server_parse($this->socket, "220") )
396  $_retVal = $this->socket;
397  }
398  // This connection attempt failed.
399  else
400  {
401  // @CHANGE LDR
402  if (empty($this->errstr)) $this->errstr='Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort();
403  $this->_setErr($this->errno, $this->errstr);
404  $_retVal = false;
405  }
406  }
407 
408  return $_retVal;
409  }
410 
411  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
418  {
419  // phpcs:enable
420  global $conf;
421 
422  // Send the RFC2554 specified EHLO.
423  // This improvment as provided by 'SirSir' to
424  // accomodate both SMTP AND ESMTP capable servers
425  $host=$this->getHost();
426  $usetls = preg_match('@tls://@i',$host);
427 
428  $host=preg_replace('@tcp://@i','',$host); // Remove prefix
429  $host=preg_replace('@ssl://@i','',$host); // Remove prefix
430  $host=preg_replace('@tls://@i','',$host); // Remove prefix
431 
432  if ($usetls) $host='tls://'.$host;
433 
434  $hosth = $host;
435 
436  if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO))
437  {
438  // If the from to is 'aaa <bbb@ccc.com>', we will keep 'ccc.com'
439  $hosth = $this->getFrom('addr');
440  $hosth = preg_replace('/^.*</', '', $hosth);
441  $hosth = preg_replace('/>.*$/', '', $hosth);
442  $hosth = preg_replace('/.*@/', '', $hosth);
443  }
444 
445  if ( $_retVal = $this->socket_send_str('EHLO ' . $hosth, '250') )
446  {
447  if ($usetls)
448  {
449  /*
450  The following dialog illustrates how a client and server can start a TLS STARTTLS session
451  S: <waits for connection on TCP port 25>
452  C: <opens connection>
453  S: 220 mail.imc.org SMTP service ready
454  C: EHLO mail.ietf.org
455  S: 250-mail.imc.org offers a warm hug of welcome
456  S: 250 STARTTLS
457  C: STARTTLS
458  S: 220 Go ahead
459  C: <starts TLS negotiation>
460  C & S: <negotiate a TLS session>
461  C & S: <check result of negotiation>
462  // Second pass EHLO
463  C: EHLO client-domain.com
464  S: 250-server-domain.com
465  S: 250 AUTH LOGIN
466  C: <continues by sending an SMTP command
467  */
468  if (!$_retVal = $this->socket_send_str('STARTTLS', 220))
469  {
470  $this->_setErr(131, 'STARTTLS connection is not supported.');
471  return $_retVal;
472  }
473 
474  // Before 5.6.7:
475  // STREAM_CRYPTO_METHOD_SSLv23_CLIENT = STREAM_CRYPTO_METHOD_SSLv2_CLIENT|STREAM_CRYPTO_METHOD_SSLv3_CLIENT
476  // STREAM_CRYPTO_METHOD_TLS_CLIENT = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
477  // PHP >= 5.6.7:
478  // STREAM_CRYPTO_METHOD_SSLv23_CLIENT = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
479  // STREAM_CRYPTO_METHOD_TLS_CLIENT = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT
480 
481  $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT;
482  if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) {
483  $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
484  $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
485  }
486 
487  if (!stream_socket_enable_crypto($this->socket, true, $crypto_method))
488  {
489  $this->_setErr(132, 'STARTTLS connection failed.');
490  return $_retVal;
491  }
492  // Most server servers expect a 2nd pass of EHLO after TLS is established to get another time
493  // the answer with list of supported AUTH methods. They may differs between non STARTTLS and with STARTTLS.
494  if (!$_retVal = $this->socket_send_str('EHLO '.$host, '250'))
495  {
496  $this->_setErr(126, '"' . $host . '" does not support authenticated connections.');
497  return $_retVal;
498  }
499  }
500  // Send Authentication to Server
501  // Check for errors along the way
502  $this->socket_send_str('AUTH LOGIN', '334');
503 
504  // User name will not return any error, server will take anything we give it.
505  $this->socket_send_str(base64_encode($this->_smtpsID), '334');
506 
507  // The error here just means the ID/password combo doesn't work.
508  // There is not a method to determine which is the problem, ID or password
509  if ( ! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') )
510  $this->_setErr(130, 'Invalid Authentication Credentials.');
511  }
512  else
513  {
514  $this->_setErr(126, '"' . $host . '" does not support authenticated connections.');
515  }
516 
517  return $_retVal;
518  }
519 
528  function sendMsg($_bolTestMsg = false, $_bolDebug = false)
529  {
530  global $conf;
531 
535  $_retVal = false;
536 
537  // Connect to Server
538  if ( $this->socket = $this->_server_connect() )
539  {
540  // If a User ID *and* a password is given, assume Authentication is desired
541  if( !empty($this->_smtpsID) && !empty($this->_smtpsPW) )
542  {
543  // Send the RFC2554 specified EHLO.
544  $_retVal = $this->_server_authenticate();
545  }
546 
547  // This is a "normal" SMTP Server "handshack"
548  else
549  {
550  // Send the RFC821 specified HELO.
551  $host=$this->getHost();
552  $usetls = preg_match('@tls://@i',$host);
553 
554  $host=preg_replace('@tcp://@i','',$host); // Remove prefix
555  $host=preg_replace('@ssl://@i','',$host); // Remove prefix
556  $host=preg_replace('@tls://@i','',$host); // Remove prefix
557 
558  $hosth = $host;
559 
560  if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO))
561  {
562  // If the from to is 'aaa <bbb@ccc.com>', we will keep 'ccc.com'
563  $hosth = $this->getFrom('addr');
564  $hosth = preg_replace('/^.*</', '', $hosth);
565  $hosth = preg_replace('/>.*$/', '', $hosth);
566  $hosth = preg_replace('/.*@/', '', $hosth);
567  }
568 
569  $_retVal = $this->socket_send_str('HELO ' . $hosth, '250');
570  }
571 
572  // Well, did we get to the server?
573  if ( $_retVal )
574  {
575  // From this point onward most server response codes should be 250
576  // Specify who the mail is from....
577  // This has to be the raw email address, strip the "name" off
578  $this->socket_send_str('MAIL FROM: ' . $this->getFrom('addr'), '250');
579 
580  // 'RCPT TO:' must be given a single address, so this has to loop
581  // through the list of addresses, regardless of TO, CC or BCC
582  // and send it out "single file"
583  foreach ( $this->get_RCPT_list() as $_address )
584  {
585  /* Note:
586  * BCC email addresses must be listed in the RCPT TO command list,
587  * but the BCC header should not be printed under the DATA command.
588  * http://stackoverflow.com/questions/2750211/sending-bcc-emails-using-a-smtp-server
589  */
590 
591  /*
592  * TODO
593  * After each 'RCPT TO:' is sent, we need to make sure it was kosher,
594  * if not, the whole message will fail
595  * If any email address fails, we will need to RESET the connection,
596  * mark the last address as "bad" and start the address loop over again.
597  * If any address fails, the entire message fails.
598  */
599  $this->socket_send_str('RCPT TO: <' . $_address . '>', '250');
600  }
601 
602  // Tell the server we are ready to start sending data
603  // with any custom headers...
604  // This is the last response code we look for until the end of the message.
605  $this->socket_send_str('DATA', '354');
606 
607  // Now we are ready for the message...
608  // Ok, all the ingredients are mixed in let's cook this puppy...
609  $this->socket_send_str($this->getHeader().$this->getBodyContent() . "\r\n" . '.', '250');
610 
611  // Now tell the server we are done and close the socket...
612  fputs($this->socket, 'QUIT');
613  fclose($this->socket);
614  }
615  }
616 
617  return $_retVal;
618  }
619 
620  // =============================================================
621  // ** Setter & Getter methods
622 
623  // ** Basic System configuration
624 
650  function setConfig($_strConfigPath = null)
651  {
656  $_retVal = true;
657 
658  // if we have a path...
659  if ( ! empty ($_strConfigPath) )
660  {
661  // If the path is not valid, this will NOT generate an error,
662  // it will simply return false.
663  if ( ! @include $_strConfigPath)
664  {
665  $this->_setErr(110, '"' . $_strConfigPath . '" is not a valid path.');
666  $_retVal = false;
667  }
668  }
669 
670  // Read the Systems php.ini file
671  else
672  {
673  // Set these properties ONLY if they are set in the php.ini file.
674  // Otherwise the default values will be used.
675  if ( $_host = ini_get('SMTPs') )
676  $this->setHost($_host);
677 
678  if ( $_port = ini_get('smtp_port') )
679  $this->setPort($_port);
680 
681  if ( $_from = ini_get('sendmail_from') )
682  $this->setFrom($_from);
683  }
684 
685  // Send back what we have
686  return $_retVal;
687  }
688 
698  function setTransportType($_type = 0)
699  {
700  if ( ( is_numeric($_type) ) &&
701  ( ( $_type >= 0 ) && ( $_type <= 3 ) ) )
702  $this->_transportType = $_type;
703  }
704 
713  function getTransportType()
714  {
715  return $this->_transportType;
716  }
717 
725  function setMailPath($_path)
726  {
727  // This feature is not yet implemented
728  return true;
729 
730  //if ( $_path ) $this->_mailPath = $_path;
731  }
732 
741  function setHost($_strHost)
742  {
743  if ( $_strHost )
744  $this->_smtpsHost = $_strHost;
745  }
746 
753  function getHost()
754  {
755  return $this->_smtpsHost;
756  }
757 
766  function setPort($_intPort)
767  {
768  if ( ( is_numeric($_intPort) ) &&
769  ( ( $_intPort >= 1 ) && ( $_intPort <= 65536 ) ) )
770  $this->_smtpsPort = $_intPort;
771  }
772 
779  function getPort()
780  {
781  return $this->_smtpsPort;
782  }
783 
790  function setID($_strID)
791  {
792  $this->_smtpsID = $_strID;
793  }
794 
800  function getID()
801  {
802  return $this->_smtpsID;
803  }
804 
811  function setPW($_strPW)
812  {
813  $this->_smtpsPW = $_strPW;
814  }
815 
821  function getPW()
822  {
823  return $this->_smtpsPW;
824  }
825 
833  function setCharSet($_strCharSet)
834  {
835  if ( $_strCharSet )
836  $this->_smtpsCharSet = $_strCharSet;
837  }
838 
844  function getCharSet()
845  {
846  return $this->_smtpsCharSet;
847  }
848 
864  function setTransEncode($_strTransEncode)
865  {
866  if (array_search($_strTransEncode, $this->_smtpsTransEncodeTypes))
867  $this->_smtpsTransEncode = $_strTransEncode;
868  }
869 
875  function getTransEncode()
876  {
878  }
879 
896  function setTransEncodeType($_strTransEncodeType)
897  {
898  if (array_search($_strTransEncodeType, $this->_smtpsTransEncodeTypes))
899  $this->_smtpsTransEncodeType = $_strTransEncodeType;
900  }
901 
908  {
909  return $this->_smtpsTransEncodeTypes[$this->_smtpsTransEncodeType];
910  }
911 
912 
913  // ** Message Construction
914 
921  function setFrom($_strFrom)
922  {
923  if ( $_strFrom )
924  $this->_msgFrom = $this->_strip_email($_strFrom);
925  }
926 
933  function getFrom($_part = true)
934  {
935  $_retValue = '';
936 
937  if ( $_part === true )
938  $_retValue = $this->_msgFrom;
939  else
940  $_retValue = $this->_msgFrom[$_part];
941 
942  return $_retValue;
943  }
944 
951  function setReplyTo($_strReplyTo)
952  {
953  if ( $_strReplyTo )
954  $this->_msgReplyTo = $this->_strip_email($_strReplyTo);
955  }
956 
963  function getReplyTo($_part = true)
964  {
965  $_retValue = '';
966 
967  if ( $_part === true )
968  $_retValue = $this->_msgReplyTo;
969  else
970  $_retValue = $this->_msgReplyTo[$_part];
971 
972  return $_retValue;
973  }
974 
987  function _buildAddrList($_type, $_addrList)
988  {
989  // Pull existing list
990  $aryHost = $this->_msgRecipients;
991 
992  // Only run this if we have something
993  if ( !empty ($_addrList ))
994  {
995  // $_addrList can be a STRING or an array
996  if ( is_string($_addrList) )
997  {
998  // This could be a COMMA delimited string
999  if ( strstr($_addrList, ',') )
1000  // "explode "list" into an array
1001  $_addrList = explode(',', $_addrList);
1002 
1003  // Stick it in an array
1004  else
1005  $_addrList = array($_addrList);
1006  }
1007 
1008  // take the array of addresses and split them further
1009  foreach ( $_addrList as $_strAddr )
1010  {
1011  // Strip off the end '>'
1012  $_strAddr = str_replace('>', '', $_strAddr);
1013 
1014  // Seperate "Real Name" from eMail address
1015  $_tmpaddr = null;
1016  $_tmpaddr = explode('<', $_strAddr);
1017 
1018  // We have a "Real Name" and eMail address
1019  if ( count($_tmpaddr) == 2 )
1020  {
1021  $_tmpHost = explode('@', $_tmpaddr[1]);
1022  $_tmpaddr[0] = trim($_tmpaddr[0], ' ">');
1023  $aryHost[$_tmpHost[1]][$_type][$_tmpHost[0]] = $_tmpaddr[0];
1024  }
1025  // We only have an eMail address
1026  else
1027  {
1028  // Strip off the beggining '<'
1029  $_strAddr = str_replace('<', '', $_strAddr);
1030 
1031  $_tmpHost = explode('@', $_strAddr);
1032  $_tmpHost[0] = trim($_tmpHost[0]);
1033  $_tmpHost[1] = trim($_tmpHost[1]);
1034 
1035  $aryHost[$_tmpHost[1]][$_type][$_tmpHost[0]] = '';
1036  }
1037  }
1038  }
1039  // replace list
1040  $this->_msgRecipients = $aryHost;
1041  }
1042 
1043  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
1060  function _strip_email($_strAddr)
1061  {
1062  // phpcs:enable
1063  // Keep the orginal
1064  $_aryEmail['org'] = $_strAddr;
1065 
1066  // Set entire string to Lower Case
1067  $_strAddr = strtolower($_strAddr);
1068 
1069  // Drop "stuff' off the end
1070  $_strAddr = trim($_strAddr, ' ">');
1071 
1072  // Seperate "Real Name" from eMail address, if we have one
1073  $_tmpAry = explode('<', $_strAddr);
1074 
1075  // Do we have a "Real name"
1076  if ( count($_tmpAry) == 2 )
1077  {
1078  // We may not really have a "Real Name"
1079  if ( $_tmpAry[0])
1080  $_aryEmail['real'] = trim($_tmpAry[0], ' ">');
1081 
1082  $_aryEmail['addr'] = $_tmpAry[1];
1083  }
1084  else
1085  $_aryEmail['addr'] = $_tmpAry[0];
1086 
1087  // Pull User Name and Host.tld apart
1088  list($_aryEmail['user'], $_aryEmail['host'] ) = explode('@', $_aryEmail['addr']);
1089 
1090  // Put the brackets back around the address
1091  $_aryEmail['addr'] = '<' . $_aryEmail['addr'] . '>';
1092 
1093  return $_aryEmail;
1094  }
1095 
1096  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
1104  function get_RCPT_list()
1105  {
1106  // phpcs:enable
1110  $_RCPT_list=array();
1111 
1112  // walk down Recipients array and pull just email addresses
1113  foreach ( $this->_msgRecipients as $_host => $_list )
1114  {
1115  foreach ( $_list as $_subList )
1116  {
1117  foreach ( $_subList as $_name => $_addr )
1118  {
1119  // build RCPT list
1120  $_RCPT_list[] = $_name . '@' . $_host;
1121  }
1122  }
1123  }
1124 
1125  return $_RCPT_list;
1126  }
1127 
1128  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
1135  function get_email_list($_which = null)
1136  {
1137  // phpcs:enable
1138  // We need to know which address segment to pull
1139  if ( $_which )
1140  {
1141  // Make sure we have addresses to process
1142  if ( $this->_msgRecipients )
1143  {
1144  $_RCPT_list=array();
1145  // walk down Recipients array and pull just email addresses
1146  foreach ( $this->_msgRecipients as $_host => $_list )
1147  {
1148  if ( $this->_msgRecipients[$_host][$_which] )
1149  {
1150  foreach ( $this->_msgRecipients[$_host][$_which] as $_addr => $_realName )
1151  {
1152  if ( $_realName ) // @CHANGE LDR
1153  {
1154  $_realName = '"' . $_realName . '"';
1155  $_RCPT_list[] = $_realName . ' <' . $_addr . '@' . $_host . '>';
1156  }
1157  else
1158  {
1159  $_RCPT_list[] = $_addr . '@' . $_host;
1160  }
1161  }
1162  }
1163  }
1164 
1165  return implode(', ', $_RCPT_list);
1166  }
1167  else
1168  {
1169  $this->_setErr(101, 'No eMail Address for message to be sent to.');
1170  return false;
1171  }
1172  }
1173  else
1174  {
1175  $this->_setErr(102, 'eMail type not defined.');
1176  return false;
1177  }
1178  }
1179 
1186  function setTO($_addrTo)
1187  {
1188  if ( $_addrTo )
1189  $this->_buildAddrList('to', $_addrTo);
1190  }
1191 
1197  function getTo()
1198  {
1199  return $this->get_email_list('to');
1200  }
1201 
1208  function setCC($_strCC)
1209  {
1210  if ( $_strCC )
1211  $this->_buildAddrList('cc', $_strCC);
1212  }
1213 
1219  function getCC()
1220  {
1221  return $this->get_email_list('cc');
1222  }
1223 
1230  function setBCC($_strBCC)
1231  {
1232  if ( $_strBCC )
1233  $this->_buildAddrList('bcc', $_strBCC);
1234  }
1235 
1241  function getBCC()
1242  {
1243  return $this->get_email_list('bcc');
1244  }
1245 
1252  function setSubject($_strSubject = '')
1253  {
1254  if ( $_strSubject )
1255  $this->_msgSubject = $_strSubject;
1256  }
1257 
1263  function getSubject()
1264  {
1265  return $this->_msgSubject;
1266  }
1267 
1273  function getHeader()
1274  {
1275  global $conf;
1276 
1277  $_header = 'From: ' . $this->getFrom('org') . "\r\n"
1278  . 'To: ' . $this->getTO() . "\r\n";
1279 
1280  if ( $this->getCC() )
1281  $_header .= 'Cc: ' . $this->getCC() . "\r\n";
1282 
1283  /* Note:
1284  * BCC email addresses must be listed in the RCPT TO command list,
1285  * but the BCC header should not be printed under the DATA command.
1286  * So it is included into the function sendMsg() but not here.
1287  * http://stackoverflow.com/questions/2750211/sending-bcc-emails-using-a-smtp-server
1288  */
1289  /*
1290  if ( $this->getBCC() )
1291  $_header .= 'Bcc: ' . $this->getBCC() . "\r\n";
1292  */
1293 
1294  $host=$this->getHost();
1295  $usetls = preg_match('@tls://@i',$host);
1296 
1297  $host=preg_replace('@tcp://@i','',$host); // Remove prefix
1298  $host=preg_replace('@ssl://@i','',$host); // Remove prefix
1299  $host=preg_replace('@tls://@i','',$host); // Remove prefix
1300 
1301  $host=dol_getprefix('email');
1302 
1303  //NOTE: Message-ID should probably contain the username of the user who sent the msg
1304  $_header .= 'Subject: ' . $this->getSubject() . "\r\n";
1305  $_header .= 'Date: ' . date("r") . "\r\n";
1306 
1307  $trackid = $this->getTrackId();
1308  if ($trackid)
1309  {
1310  // References is kept in response and Message-ID is returned into In-Reply-To:
1311  $_header .= 'Message-ID: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n";
1312  $_header .= 'References: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n";
1313  $_header .= 'X-Dolibarr-TRACKID: ' . $trackid . '@' . $host . "\r\n";
1314  }
1315  else
1316  {
1317  $_header .= 'Message-ID: <' . time() . '.SMTPs@' . $host . ">\r\n";
1318  }
1319  if (! empty($_SERVER['REMOTE_ADDR'])) $_header .= "X-RemoteAddr: " . $_SERVER['REMOTE_ADDR']. "\r\n";
1320  if ( $this->getMoreInHeader() )
1321  $_header .= $this->getMoreInHeader(); // Value must include the "\r\n";
1322 
1323  //$_header .=
1324  // 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"
1325  // 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n";
1326 
1327  if ( $this->getSensitivity() )
1328  $_header .= 'Sensitivity: ' . $this->getSensitivity() . "\r\n";
1329 
1330  if ( $this->_msgPriority != 3 )
1331  $_header .= $this->getPriority();
1332 
1333 
1334  // @CHANGE LDR
1335  if ( $this->getDeliveryReceipt() )
1336  $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n";
1337  if ( $this->getErrorsTo() )
1338  $_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n";
1339  if ( $this->getReplyTo() )
1340  $_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n";
1341 
1342  $_header .= 'X-Mailer: Dolibarr version ' . DOL_VERSION .' (using SMTPs Mailer)' . "\r\n";
1343  $_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART?'MAIN_MAIL_USE_MULTI_PART':'No MAIN_MAIL_USE_MULTI_PART') . "\r\n";
1344  $_header .= 'Mime-Version: 1.0' . "\r\n";
1345 
1346 
1347  return $_header;
1348  }
1349 
1357  function setBodyContent($strContent, $strType = 'plain')
1358  {
1359  //if ( $strContent )
1360  //{
1361  if ( $strType == 'html' )
1362  $strMimeType = 'text/html';
1363  else
1364  $strMimeType = 'text/plain';
1365 
1366  // Make RFC821 Compliant, replace bare linefeeds
1367  $strContent = preg_replace("/(?<!\r)\n/si", "\r\n", $strContent);
1368 
1369  $strContentAltText = '';
1370  if ($strType == 'html')
1371  {
1372  // Similar code to forge a text from html is also in CMailFile.class.php
1373  $strContentAltText = preg_replace("/<br\s*[^>]*>/"," ", $strContent);
1374  $strContentAltText = html_entity_decode(strip_tags($strContentAltText));
1375  $strContentAltText = rtrim(wordwrap($strContentAltText, 75, "\r\n"));
1376  }
1377 
1378  // Make RFC2045 Compliant
1379  //$strContent = rtrim(chunk_split($strContent)); // Function chunck_split seems ko if not used on a base64 content
1380  $strContent = rtrim(wordwrap($strContent, 75, "\r\n")); // TODO Using this method creates unexpected line break on text/plain content.
1381 
1382  $this->_msgContent[$strType] = array();
1383 
1384  $this->_msgContent[$strType]['mimeType'] = $strMimeType;
1385  $this->_msgContent[$strType]['data'] = $strContent;
1386  $this->_msgContent[$strType]['dataText'] = $strContentAltText;
1387 
1388  if ( $this->getMD5flag() )
1389  $this->_msgContent[$strType]['md5'] = dol_hash($strContent, 3);
1390  //}
1391  }
1392 
1398  function getBodyContent()
1399  {
1400  global $conf;
1401 
1402  // Generate a new Boundary string
1403  $this->_setBoundary();
1404 
1405  // What type[s] of content do we have
1406  $_types = array_keys($this->_msgContent);
1407 
1408  // How many content types do we have
1409  $keyCount = count($_types);
1410 
1411  // If we have ZERO, we have a problem
1412  if( $keyCount === 0 )
1413  die ("Sorry, no content");
1414 
1415  // If we have ONE, we can use the simple format
1416  else if( $keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART))
1417  {
1418  $_msgData = $this->_msgContent;
1419  $_msgData = $_msgData[$_types[0]];
1420 
1421  $content = 'Content-Type: ' . $_msgData['mimeType'] . '; charset="' . $this->getCharSet() . '"' . "\r\n"
1422  . 'Content-Transfer-Encoding: ' . $this->getTransEncodeType() . "\r\n"
1423  . 'Content-Disposition: inline' . "\r\n"
1424  . 'Content-Description: Message' . "\r\n";
1425 
1426  if ( $this->getMD5flag() )
1427  $content .= 'Content-MD5: ' . $_msgData['md5'] . "\r\n";
1428 
1429  $content .= "\r\n"
1430  . $_msgData['data'] . "\r\n";
1431  }
1432 
1433  // If we have more than ONE, we use the multi-part format
1434  else if( $keyCount >= 1 || ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART))
1435  {
1436  // Since this is an actual multi-part message
1437  // We need to define a content message Boundary
1438  // NOTE: This was 'multipart/alternative', but Windows based mail servers have issues with this.
1439 
1440  //$content = 'Content-Type: multipart/related; boundary="' . $this->_getBoundary() . '"' . "\r\n";
1441  $content = 'Content-Type: multipart/mixed; boundary="' . $this->_getBoundary('mixed') . '"' . "\r\n";
1442 
1443  // . "\r\n"
1444  // . 'This is a multi-part message in MIME format.' . "\r\n";
1445  $content .= "Content-Transfer-Encoding: 8bit\r\n";
1446  $content .= "\r\n";
1447 
1448  $content .= "--" . $this->_getBoundary('mixed') . "\r\n";
1449 
1450  if (key_exists('image', $this->_msgContent)) // If inline image found
1451  {
1452  $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n";
1453  $content .= "\r\n";
1454  $content .= "--" . $this->_getBoundary('alternative') . "\r\n";
1455  }
1456 
1457 
1458  // $this->_msgContent must be sorted with key 'text' or 'html' first then 'image' then 'attachment'
1459 
1460 
1461  // Loop through message content array
1462  foreach ($this->_msgContent as $type => $_content )
1463  {
1464  if ( $type == 'attachment' )
1465  {
1466  // loop through all attachments
1467  foreach ( $_content as $_file => $_data )
1468  {
1469  $content .= "--" . $this->_getBoundary('mixed') . "\r\n"
1470  . 'Content-Disposition: attachment; filename="' . $_data['fileName'] . '"' . "\r\n"
1471  . 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['fileName'] . '"' . "\r\n"
1472  . 'Content-Transfer-Encoding: base64' . "\r\n"
1473  . 'Content-Description: ' . $_data['fileName'] ."\r\n";
1474 
1475  if ( $this->getMD5flag() )
1476  $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n";
1477 
1478  $content .= "\r\n" . $_data['data'] . "\r\n\r\n";
1479  }
1480  }
1481  // @CHANGE LDR
1482  else if ( $type == 'image' )
1483  {
1484  // loop through all images
1485  foreach ( $_content as $_image => $_data )
1486  {
1487  $content .= "--" . $this->_getBoundary('related') . "\r\n"; // always related for an inline image
1488 
1489  $content .= 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['imageName'] . '"' . "\r\n"
1490  . 'Content-Transfer-Encoding: base64' . "\r\n"
1491  . 'Content-Disposition: inline; filename="' . $_data['imageName'] . '"' . "\r\n"
1492  . 'Content-ID: <' . $_data['cid'] . '> ' . "\r\n";
1493 
1494  if ( $this->getMD5flag() )
1495  $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n";
1496 
1497  $content .= "\r\n"
1498  . $_data['data'] . "\r\n";
1499  }
1500 
1501  // always end related and end alternative after inline images
1502  $content.= "--" . $this->_getBoundary('related') . "--" . "\r\n";
1503  $content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n";
1504  $content.= "\r\n";
1505  }
1506  else
1507  {
1508  if (key_exists('image', $this->_msgContent))
1509  {
1510  $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n";
1511  $content.= "\r\n" . ($_content['dataText']?$_content['dataText']:strip_tags($_content['data'])) . "\r\n"; // Add plain text message
1512  $content.= "--" . $this->_getBoundary('alternative') . "\r\n";
1513  $content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n";
1514  $content.= "\r\n";
1515  $content.= "--" . $this->_getBoundary('related') . "\r\n";
1516  }
1517 
1518  if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part
1519  {
1520  $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n";
1521  $content .= "\r\n";
1522  $content .= "--" . $this->_getBoundary('alternative') . "\r\n";
1523 
1524  $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n";
1525  $content.= "\r\n". $_content['dataText'] . "\r\n";
1526  $content.= "--" . $this->_getBoundary('alternative') . "\r\n";
1527  }
1528 
1529  $content .= 'Content-Type: ' . $_content['mimeType'] . '; '
1530  // . 'charset="' . $this->getCharSet() . '"';
1531  . 'charset=' . $this->getCharSet() . '';
1532 
1533  // $content .= ( $type == 'html') ? '; name="HTML Part"' : '';
1534  $content .= "\r\n";
1535  // $content .= 'Content-Transfer-Encoding: ';
1536  // $content .= ($type == 'html') ? 'quoted-printable' : $this->getTransEncodeType();
1537  // $content .= "\r\n"
1538  // . 'Content-Disposition: inline' . "\r\n"
1539  // . 'Content-Description: ' . $type . ' message' . "\r\n";
1540 
1541  if ( $this->getMD5flag() )
1542  $content .= 'Content-MD5: ' . $_content['md5'] . "\r\n";
1543 
1544  $content .= "\r\n" . $_content['data'] . "\r\n";
1545 
1546  if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part after html part
1547  {
1548  $content.= "--" . $this->_getBoundary('alternative') . "--". "\r\n";
1549  }
1550 
1551  $content .= "\r\n";
1552  }
1553  }
1554 
1555  // Close message boundries
1556  // $content .= "\r\n--" . $this->_getBoundary() . '--' . "\r\n" ;
1557  $content .= "--" . $this->_getBoundary('mixed') . '--' . "\r\n" ;
1558  }
1559 
1560  return $content;
1561  }
1562 
1572  function setAttachment($strContent, $strFileName = 'unknown', $strMimeType = 'unknown')
1573  {
1574  if ( $strContent )
1575  {
1576  $strContent = rtrim(chunk_split(base64_encode($strContent), 76, "\r\n")); // 76 max is defined into http://tools.ietf.org/html/rfc2047
1577 
1578  $this->_msgContent['attachment'][$strFileName]['mimeType'] = $strMimeType;
1579  $this->_msgContent['attachment'][$strFileName]['fileName'] = $strFileName;
1580  $this->_msgContent['attachment'][$strFileName]['data'] = $strContent;
1581 
1582  if ( $this->getMD5flag() )
1583  $this->_msgContent['attachment'][$strFileName]['md5'] = dol_hash($strContent, 3);
1584  }
1585  }
1586 
1587 
1588  // @CHANGE LDR
1589 
1600  function setImageInline($strContent, $strImageName = 'unknown', $strMimeType = 'unknown', $strImageCid = 'unknown')
1601  {
1602  if ($strContent)
1603  {
1604  $this->_msgContent['image'][$strImageName]['mimeType'] = $strMimeType;
1605  $this->_msgContent['image'][$strImageName]['imageName'] = $strImageName;
1606  $this->_msgContent['image'][$strImageName]['cid'] = $strImageCid;
1607  $this->_msgContent['image'][$strImageName]['data'] = $strContent;
1608 
1609  if ( $this->getMD5flag() )
1610  $this->_msgContent['image'][$strImageName]['md5'] = dol_hash($strContent, 3);
1611  }
1612  }
1613  // END @CHANGE LDR
1614 
1615 
1627  function setSensitivity($_value = 0)
1628  {
1629  if ( ( is_numeric($_value) ) &&
1630  ( ( $_value >= 0 ) && ( $_value <= 3 ) ) )
1631  $this->_msgSensitivity = $_value;
1632  }
1633 
1644  function getSensitivity()
1645  {
1646  return $this->_arySensitivity[$this->_msgSensitivity];
1647  }
1648 
1662  function setPriority( $_value = 3 )
1663  {
1664  if ( ( is_numeric($_value) ) &&
1665  ( ( $_value >= 0 ) && ( $_value <= 5 ) ) )
1666  $this->_msgPriority = $_value;
1667  }
1668 
1681  function getPriority()
1682  {
1683  return 'Importance: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n"
1684  . 'Priority: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n"
1685  . 'X-Priority: ' . $this->_msgPriority . ' (' . $this->_aryPriority[$this->_msgPriority] . ')' . "\r\n";
1686  }
1687 
1694  function setMD5flag($_flag = false)
1695  {
1696  $this->_smtpMD5 = $_flag;
1697  }
1698 
1704  function getMD5flag()
1705  {
1706  return $this->_smtpMD5;
1707  }
1708 
1717  function setXheader($strXdata)
1718  {
1719  if ( $strXdata )
1720  $this->_msgXheader[] = $strXdata;
1721  }
1722 
1728  function getXheader()
1729  {
1730  return $this->_msgXheader;
1731  }
1732 
1738  function _setBoundary()
1739  {
1740  $this->_smtpsBoundary = "multipart_x." . time() . ".x_boundary";
1741  $this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2"), 3);
1742  $this->_smtpsAlternativeBoundary = 'mul_'.dol_hash(uniqid("dolibarr3"), 3);
1743  }
1744 
1751  function _getBoundary($type='mixed')
1752  {
1753  if ($type == 'mixed') return $this->_smtpsBoundary;
1754  else if ($type == 'related') return $this->_smtpsRelatedBoundary;
1755  else if ($type == 'alternative') return $this->_smtpsAlternativeBoundary;
1756  }
1757 
1758  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
1767  function server_parse($socket, $response)
1768  {
1769  // phpcs:enable
1774  $_retVal = true;
1775 
1776  $server_response = '';
1777 
1778  // avoid infinite loop
1779  $limit=0;
1780 
1781  while (substr($server_response,3,1) != ' ' && $limit<100)
1782  {
1783  if (! ($server_response = fgets($socket, 256)))
1784  {
1785  $this->_setErr(121, "Couldn't get mail server response codes");
1786  $_retVal = false;
1787  break;
1788  }
1789  $limit++;
1790  }
1791 
1792  if (! (substr($server_response, 0, 3) == $response))
1793  {
1794  $this->_setErr(120, "Ran into problems sending Mail.\r\nResponse: $server_response");
1795  $_retVal = false;
1796  }
1797 
1798  return $_retVal;
1799  }
1800 
1801  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
1810  function socket_send_str( $_strSend, $_returnCode = null, $CRLF = "\r\n" )
1811  {
1812  // phpcs:enable
1813  if ($this->_debug) $this->log.=$_strSend; // @CHANGE LDR for log
1814  fputs($this->socket, $_strSend . $CRLF);
1815  if ($this->_debug) $this->log.=' ('.$_returnCode.')' . $CRLF;
1816 
1817  if ( $_returnCode )
1818  return $this->server_parse($this->socket, $_returnCode);
1819  }
1820 
1821  // =============================================================
1822  // ** Error handling methods
1823 
1831  function _setErr( $_errNum, $_errMsg )
1832  {
1833  $this->_smtpsErrors[] = array(
1834  'num' => $_errNum,
1835  'msg' => $_errMsg,
1836  );
1837  }
1838 
1844  function getErrors()
1845  {
1846  $_errMsg = array();
1847 
1848  if (is_array($this->_smtpsErrors))
1849  {
1850  foreach ( $this->_smtpsErrors as $_err => $_info )
1851  {
1852  $_errMsg[] = 'Error [' . $_info['num'] .']: '. $_info['msg'];
1853  }
1854  }
1855 
1856  return implode("\n", $_errMsg);
1857  }
1858 }
1859 
1860 
1861 // =============================================================
1862 // ** CSV Version Control Info
1863 
setDebug($_vDebug=false)
Set debug.
getID()
Retrieves the User Name for authentication on Mail Server.
$_debug
Place Class in" debug" mode.
$_smtpsPW
Secure SMTP Server access Password This can be defined via a INI file or via a setter method...
Definition: smtps.class.php:69
$_transportType
Determines the method inwhich the message are to be sent.
getTransportType()
Return the method inwhich the message is to be sent.
getPW()
Retrieves the User Password for authentication on Mail Server.
setSensitivity($_value=0)
Message Content Sensitivity Message Sensitivity values:
getTransEncodeType()
Retrieves the Content-Transfer-Encoding.
setTransEncodeType($_strTransEncodeType)
Content-Transfer-Encoding, Defaulted to &#39;0&#39; [ZERO] This can be changed for 2byte characers sets Known...
_getBoundary($type='mixed')
Retrieves the MIME message Boundary.
setCharSet($_strCharSet)
Character set used for current message Character set is defaulted to &#39;iso-8859-1&#39;;.
$_msgFrom
Who sent the Message This can be defined via a INI file or via a setter method.
Definition: smtps.class.php:75
setFrom($_strFrom)
FROM Address from which mail will be sent.
sendMsg($_bolTestMsg=false, $_bolDebug=false)
Now send the message.
setPriority( $_value=3)
Message Content Priority Message Priority values:
$_msgRecipients
Who will the Message be sent to; TO, CC, BCC Multi-diminsional array containg addresses the message w...
Definition: smtps.class.php:88
getSensitivity()
Returns Message Content Sensitivity string Message Sensitivity values:
$_smtpsID
Secure SMTP Server access ID This can be defined via a INI file or via a setter method.
Definition: smtps.class.php:63
getCharSet()
Retrieves the Character set used for current message.
buildRCPTlist()
build RECIPIENT List, all addresses who will recieve this message
Class to construct and send SMTP compliant email, even to a secure SMTP server, regardless of platfor...
Definition: smtps.class.php:46
setXheader($strXdata)
Message X-Header Content This is a simple "insert".
getFrom($_part=true)
Retrieves the Address from which mail will be sent.
_server_authenticate()
Attempt mail server authentication for a secure connection.
getHeader()
Constructes and returns message header.
$_msgXheader
Custom X-Headers.
$_smtpTimeout
Sets the SMTP server timeout in seconds.
$_msgContent
Message Content.
Definition: smtps.class.php:98
setBCC($_strBCC)
BCC Address[es] inwhich to send mail to.
$_smtpMD5
Determines whether to calculate message MD5 checksum.
get_email_list($_which=null)
Returns an array of addresses for a specific type; TO, CC or BCC.
$_smtpsTransEncodeTypes
Content-Transfer-Encoding.
getMoreInHeader()
get moreInHeader
setBodyContent($strContent, $strType='plain')
Message Content.
getMD5flag()
Gets flag which determines whether to calculate message MD5 checksum.
setTransEncode($_strTransEncode)
Content-Transfer-Encoding, Defaulted to &#39;7bit&#39; This can be changed for 2byte characers sets Known Enc...
getBodyContent()
Retrieves the Message Content.
get_RCPT_list()
Returns an array of bares addresses for use with &#39;RCPT TO:&#39; This is a "build as you go" method...
setHost($_strHost)
Defines the Host Name or IP of the Mail Server to use.
getTo()
Retrieves the TO Address[es] inwhich to send mail to.
setErrorsTo($_strErrorsTo)
Set errors to.
_buildAddrList($_type, $_addrList)
Inserts given addresses into structured format.
$_arySensitivity
Message Sensitivity.
$_log_level
Defines log level 0 - no logging 1 - connectivity logging 2 - message generation logging 3 - detail l...
setMoreInHeader($_val='')
Set moreInHeader.
setCC($_strCC)
CC Address[es] inwhich to send mail to.
setImageInline($strContent, $strImageName='unknown', $strMimeType='unknown', $strImageCid='unknown')
Image attachments are added to the content array as sub-arrays, allowing for multiple images for each...
_server_connect()
Attempt a connection to mail server.
$_msgReplyTo
Where are replies and errors to be sent to This can be defined via a INI file or via a setter method...
Definition: smtps.class.php:81
setPort($_intPort)
Defines the Port Number of the Mail Server to use This is defaulted to &#39;25&#39; This is used only with &#39;s...
getBCC()
Retrieves the BCC Address[es] inwhich to send mail to.
setAttachment($strContent, $strFileName='unknown', $strMimeType='unknown')
File attachments are added to the content array as sub-arrays, allowing for multiple attachments for ...
setTrackId($_val='')
Set trackid.
$_smtpsHost
Host Name or IP of SMTP Server to use.
Definition: smtps.class.php:51
$_smtpsAlternativeBoundary
Alternative Boundary.
$_smtpsTransEncode
Content-Transfer-Encoding Defaulted to &#39;7bit&#39;.
setReplyTo($_strReplyTo)
Reply-To Address from which mail will be the reply-to.
getTrackId()
get trackid
server_parse($socket, $response)
This function has been modified as provided by SirSir to allow multiline responses when using SMTP Ex...
getErrors()
Returns errors codes and messages for Class.
getPort()
Retrieves the Port Number of the Mail Server to use This is used only with &#39;socket&#39; based mail transm...
setTO($_addrTo)
TO Address[es] inwhich to send mail to.
is_ip($ip)
This function evaluates a string that should be a valid IPv4 Note: For ip 169.254.0.0, it returns 0 with some PHP (5.6.24) and 2 with some minor patchs of PHP (5.6.25).
$_smtpsRelatedBoundary
Related Boundary.
setTransportType($_type=0)
Determines the method inwhich the messages are to be sent.
getHost()
Retrieves the Host Name or IP of the Mail Server to use This is used only with &#39;socket&#39; based mail tr...
getXheader()
Retrieves the Message X-Header Content.
$_aryPriority
Message Priority.
getPriority()
Message Content Priority Message Priority values:
getCC()
Retrieves the CC Address[es] inwhich to send mail to.
$_smtpsTransEncodeType
Content-Transfer-Encoding Defaulted to 0 - 7bit.
getSubject()
Retrieves the Message Subject.
$_msgSensitivity
Message Sensitivity Defaults to ZERO - None.
getDeliveryReceipt()
get delivery receipt
_strip_email($_strAddr)
Returns an array of the various parts of an email address This assumes a well formed address: ...
$_smtpsCharSet
Character set Defaulted to &#39;iso-8859-1&#39;.
setSubject($_strSubject='')
Message Subject.
$_smtpsErrors
Class error codes and messages.
_setErr( $_errNum, $_errMsg)
Defines errors codes and messages for Class.
getErrorsTo($_part=true)
Get errors to.
getReplyTo($_part=true)
Retrieves the Address from which mail will be the reply-to.
setPW($_strPW)
User Password for authentication on Mail Server.
$_mailPath
If &#39;$_transportType&#39; is set to &#39;1&#39;, then this variable is used to define the UNIX file system path to...
dol_hash($chain, $type='0')
Returns a hash of a string.
setConfig($_strConfigPath=null)
setConfig() is used to populate select class properties from either a user defined INI file or the sy...
$_msgSubject
Message Subject.
Definition: smtps.class.php:93
$_msgPriority
Message Sensitivity Defaults to 3 - Normal.
setDeliveryReceipt($_val=0)
Set delivery receipt.
$_smtpsBoundary
Boundary String for MIME seperation.
_setBoundary()
Generates Random string for MIME message Boundary.
getTransEncode()
Retrieves the Content-Transfer-Encoding.
setMailPath($_path)
Path to the sendmail execuable.
$_smtpsPort
SMTP Server Port definition.
Definition: smtps.class.php:57
setID($_strID)
User Name for authentication on Mail Server.
socket_send_str( $_strSend, $_returnCode=null, $CRLF="\")
Send str.
setMD5flag($_flag=false)
Set flag which determines whether to calculate message MD5 checksum.