dolibarr  7.0.0-beta
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 
352  function _server_connect()
353  {
354  // Default return value
355  $_retVal = true;
356 
357  // We have to make sure the HOST given is valid
358  // This is done here because '@fsockopen' will not give me this
359  // information if it failes to connect because it can't find the HOST
360  $host=$this->getHost();
361  $usetls = preg_match('@tls://@i',$host);
362 
363  $host=preg_replace('@tcp://@i','',$host); // Remove prefix
364  $host=preg_replace('@ssl://@i','',$host); // Remove prefix
365  $host=preg_replace('@tls://@i','',$host); // Remove prefix
366 
367  // @CHANGE LDR
368  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
369 
370  if ( (! is_ip($host)) && ((gethostbyname($host)) == $host))
371  {
372  $this->_setErr(99, $host . ' is either offline or is an invalid host name.');
373  $_retVal = false;
374  }
375  else
376  {
377  //See if we can connect to the SMTP server
378  if ($this->socket = @fsockopen(
379  preg_replace('@tls://@i','',$this->getHost()), // Host to 'hit', IP or domain
380  $this->getPort(), // which Port number to use
381  $this->errno, // actual system level error
382  $this->errstr, // and any text that goes with the error
383  $this->_smtpTimeout
384  )) // timeout for reading/writing data over the socket
385  {
386  // Fix from PHP SMTP class by 'Chris Ryan'
387  // Sometimes the SMTP server takes a little longer to respond
388  // so we will give it a longer timeout for the first read
389  // Windows still does not have support for this timeout function
390  if (function_exists('stream_set_timeout')) stream_set_timeout($this->socket, $this->_smtpTimeout, 0);
391 
392  // Check response from Server
393  if ( $_retVal = $this->server_parse($this->socket, "220") )
394  $_retVal = $this->socket;
395  }
396  // This connection attempt failed.
397  else
398  {
399  // @CHANGE LDR
400  if (empty($this->errstr)) $this->errstr='Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort();
401  $this->_setErr($this->errno, $this->errstr);
402  $_retVal = false;
403  }
404  }
405 
406  return $_retVal;
407  }
408 
415  {
416  global $conf;
417 
418  // Send the RFC2554 specified EHLO.
419  // This improvment as provided by 'SirSir' to
420  // accomodate both SMTP AND ESMTP capable servers
421  $host=$this->getHost();
422  $usetls = preg_match('@tls://@i',$host);
423 
424  $host=preg_replace('@tcp://@i','',$host); // Remove prefix
425  $host=preg_replace('@ssl://@i','',$host); // Remove prefix
426  $host=preg_replace('@tls://@i','',$host); // Remove prefix
427 
428  if ($usetls) $host='tls://'.$host;
429 
430  $hosth = $host;
431 
432  if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO))
433  {
434  // If the from to is 'aaa <bbb@ccc.com>', we will keep 'ccc.com'
435  $hosth = $this->getFrom('addr');
436  $hosth = preg_replace('/^.*</', '', $hosth);
437  $hosth = preg_replace('/>.*$/', '', $hosth);
438  $hosth = preg_replace('/.*@/', '', $hosth);
439  }
440 
441  if ( $_retVal = $this->socket_send_str('EHLO ' . $hosth, '250') )
442  {
443  if ($usetls)
444  {
445  /*
446  The following dialog illustrates how a client and server can start a TLS STARTTLS session
447  S: <waits for connection on TCP port 25>
448  C: <opens connection>
449  S: 220 mail.imc.org SMTP service ready
450  C: EHLO mail.ietf.org
451  S: 250-mail.imc.org offers a warm hug of welcome
452  S: 250 STARTTLS
453  C: STARTTLS
454  S: 220 Go ahead
455  C: <starts TLS negotiation>
456  C & S: <negotiate a TLS session>
457  C & S: <check result of negotiation>
458  // Second pass EHLO
459  C: EHLO client-domain.com
460  S: 250-server-domain.com
461  S: 250 AUTH LOGIN
462  C: <continues by sending an SMTP command
463  */
464  if (!$_retVal = $this->socket_send_str('STARTTLS', 220))
465  {
466  $this->_setErr(131, 'STARTTLS connection is not supported.');
467  return $_retVal;
468  }
469 
470  // Before 5.6.7:
471  // STREAM_CRYPTO_METHOD_SSLv23_CLIENT = STREAM_CRYPTO_METHOD_SSLv2_CLIENT|STREAM_CRYPTO_METHOD_SSLv3_CLIENT
472  // STREAM_CRYPTO_METHOD_TLS_CLIENT = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
473  // PHP >= 5.6.7:
474  // STREAM_CRYPTO_METHOD_SSLv23_CLIENT = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
475  // STREAM_CRYPTO_METHOD_TLS_CLIENT = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT
476 
477  $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT;
478  if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) {
479  $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
480  $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
481  }
482 
483  if (!stream_socket_enable_crypto($this->socket, true, $crypto_method))
484  {
485  $this->_setErr(132, 'STARTTLS connection failed.');
486  return $_retVal;
487  }
488  // Most server servers expect a 2nd pass of EHLO after TLS is established to get another time
489  // the answer with list of supported AUTH methods. They may differs between non STARTTLS and with STARTTLS.
490  if (!$_retVal = $this->socket_send_str('EHLO '.$host, '250'))
491  {
492  $this->_setErr(126, '"' . $host . '" does not support authenticated connections.');
493  return $_retVal;
494  }
495  }
496  // Send Authentication to Server
497  // Check for errors along the way
498  $this->socket_send_str('AUTH LOGIN', '334');
499 
500  // User name will not return any error, server will take anything we give it.
501  $this->socket_send_str(base64_encode($this->_smtpsID), '334');
502 
503  // The error here just means the ID/password combo doesn't work.
504  // There is not a method to determine which is the problem, ID or password
505  if ( ! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') )
506  $this->_setErr(130, 'Invalid Authentication Credentials.');
507  }
508  else
509  {
510  $this->_setErr(126, '"' . $host . '" does not support authenticated connections.');
511  }
512 
513  return $_retVal;
514  }
515 
524  function sendMsg($_bolTestMsg = false, $_bolDebug = false)
525  {
526  global $conf;
527 
531  $_retVal = false;
532 
533  // Connect to Server
534  if ( $this->socket = $this->_server_connect() )
535  {
536  // If a User ID *and* a password is given, assume Authentication is desired
537  if( !empty($this->_smtpsID) && !empty($this->_smtpsPW) )
538  {
539  // Send the RFC2554 specified EHLO.
540  $_retVal = $this->_server_authenticate();
541  }
542 
543  // This is a "normal" SMTP Server "handshack"
544  else
545  {
546  // Send the RFC821 specified HELO.
547  $host=$this->getHost();
548  $usetls = preg_match('@tls://@i',$host);
549 
550  $host=preg_replace('@tcp://@i','',$host); // Remove prefix
551  $host=preg_replace('@ssl://@i','',$host); // Remove prefix
552  $host=preg_replace('@tls://@i','',$host); // Remove prefix
553 
554  $hosth = $host;
555 
556  if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO))
557  {
558  // If the from to is 'aaa <bbb@ccc.com>', we will keep 'ccc.com'
559  $hosth = $this->getFrom('addr');
560  $hosth = preg_replace('/^.*</', '', $hosth);
561  $hosth = preg_replace('/>.*$/', '', $hosth);
562  $hosth = preg_replace('/.*@/', '', $hosth);
563  }
564 
565  $_retVal = $this->socket_send_str('HELO ' . $hosth, '250');
566  }
567 
568  // Well, did we get to the server?
569  if ( $_retVal )
570  {
571  // From this point onward most server response codes should be 250
572  // Specify who the mail is from....
573  // This has to be the raw email address, strip the "name" off
574  $this->socket_send_str('MAIL FROM: ' . $this->getFrom('addr'), '250');
575 
576  // 'RCPT TO:' must be given a single address, so this has to loop
577  // through the list of addresses, regardless of TO, CC or BCC
578  // and send it out "single file"
579  foreach ( $this->get_RCPT_list() as $_address )
580  {
581  /* Note:
582  * BCC email addresses must be listed in the RCPT TO command list,
583  * but the BCC header should not be printed under the DATA command.
584  * http://stackoverflow.com/questions/2750211/sending-bcc-emails-using-a-smtp-server
585  */
586 
587  /*
588  * TODO
589  * After each 'RCPT TO:' is sent, we need to make sure it was kosher,
590  * if not, the whole message will fail
591  * If any email address fails, we will need to RESET the connection,
592  * mark the last address as "bad" and start the address loop over again.
593  * If any address fails, the entire message fails.
594  */
595  $this->socket_send_str('RCPT TO: <' . $_address . '>', '250');
596  }
597 
598  // Tell the server we are ready to start sending data
599  // with any custom headers...
600  // This is the last response code we look for until the end of the message.
601  $this->socket_send_str('DATA', '354');
602 
603  // Now we are ready for the message...
604  // Ok, all the ingredients are mixed in let's cook this puppy...
605  $this->socket_send_str($this->getHeader().$this->getBodyContent() . "\r\n" . '.', '250');
606 
607  // Now tell the server we are done and close the socket...
608  fputs($this->socket, 'QUIT');
609  fclose($this->socket);
610  }
611  }
612 
613  return $_retVal;
614  }
615 
616  // =============================================================
617  // ** Setter & Getter methods
618 
619  // ** Basic System configuration
620 
646  function setConfig($_strConfigPath = null)
647  {
652  $_retVal = true;
653 
654  // if we have a path...
655  if ( ! empty ($_strConfigPath) )
656  {
657  // If the path is not valid, this will NOT generate an error,
658  // it will simply return FALSE.
659  if ( ! @include ( $_strConfigPath ) )
660  {
661  $this->_setErr(110, '"' . $_strConfigPath . '" is not a valid path.');
662  $_retVal = false;
663  }
664  }
665 
666  // Read the Systems php.ini file
667  else
668  {
669  // Set these properties ONLY if they are set in the php.ini file.
670  // Otherwise the default values will be used.
671  if ( $_host = ini_get('SMTPs') )
672  $this->setHost($_host);
673 
674  if ( $_port = ini_get('smtp_port') )
675  $this->setPort($_port);
676 
677  if ( $_from = ini_get('sendmail_from') )
678  $this->setFrom($_from);
679  }
680 
681  // Send back what we have
682  return $_retVal;
683  }
684 
694  function setTransportType($_type = 0)
695  {
696  if ( ( is_numeric($_type) ) &&
697  ( ( $_type >= 0 ) && ( $_type <= 3 ) ) )
698  $this->_transportType = $_type;
699  }
700 
709  function getTransportType()
710  {
711  return $this->_transportType;
712  }
713 
721  function setMailPath($_path)
722  {
723  // This feature is not yet implemented
724  return true;
725 
726  //if ( $_path ) $this->_mailPath = $_path;
727  }
728 
737  function setHost($_strHost)
738  {
739  if ( $_strHost )
740  $this->_smtpsHost = $_strHost;
741  }
742 
749  function getHost()
750  {
751  return $this->_smtpsHost;
752  }
753 
762  function setPort($_intPort)
763  {
764  if ( ( is_numeric($_intPort) ) &&
765  ( ( $_intPort >= 1 ) && ( $_intPort <= 65536 ) ) )
766  $this->_smtpsPort = $_intPort;
767  }
768 
775  function getPort()
776  {
777  return $this->_smtpsPort;
778  }
779 
786  function setID($_strID)
787  {
788  $this->_smtpsID = $_strID;
789  }
790 
796  function getID()
797  {
798  return $this->_smtpsID;
799  }
800 
807  function setPW($_strPW)
808  {
809  $this->_smtpsPW = $_strPW;
810  }
811 
817  function getPW()
818  {
819  return $this->_smtpsPW;
820  }
821 
829  function setCharSet($_strCharSet)
830  {
831  if ( $_strCharSet )
832  $this->_smtpsCharSet = $_strCharSet;
833  }
834 
840  function getCharSet()
841  {
842  return $this->_smtpsCharSet;
843  }
844 
860  function setTransEncode($_strTransEncode)
861  {
862  if (array_search($_strTransEncode, $this->_smtpsTransEncodeTypes))
863  $this->_smtpsTransEncode = $_strTransEncode;
864  }
865 
871  function getTransEncode()
872  {
874  }
875 
892  function setTransEncodeType($_strTransEncodeType)
893  {
894  if (array_search($_strTransEncodeType, $this->_smtpsTransEncodeTypes))
895  $this->_smtpsTransEncodeType = $_strTransEncodeType;
896  }
897 
904  {
905  return $this->_smtpsTransEncodeTypes[$this->_smtpsTransEncodeType];
906  }
907 
908 
909  // ** Message Construction
910 
917  function setFrom($_strFrom)
918  {
919  if ( $_strFrom )
920  $this->_msgFrom = $this->_strip_email($_strFrom);
921  }
922 
929  function getFrom($_part = true)
930  {
931  $_retValue = '';
932 
933  if ( $_part === true )
934  $_retValue = $this->_msgFrom;
935  else
936  $_retValue = $this->_msgFrom[$_part];
937 
938  return $_retValue;
939  }
940 
947  function setReplyTo($_strReplyTo)
948  {
949  if ( $_strReplyTo )
950  $this->_msgReplyTo = $this->_strip_email($_strReplyTo);
951  }
952 
959  function getReplyTo($_part = true)
960  {
961  $_retValue = '';
962 
963  if ( $_part === true )
964  $_retValue = $this->_msgReplyTo;
965  else
966  $_retValue = $this->_msgReplyTo[$_part];
967 
968  return $_retValue;
969  }
970 
983  function _buildAddrList($_type, $_addrList)
984  {
985  // Pull existing list
986  $aryHost = $this->_msgRecipients;
987 
988  // Only run this if we have something
989  if ( !empty ($_addrList ))
990  {
991  // $_addrList can be a STRING or an array
992  if ( is_string($_addrList) )
993  {
994  // This could be a COMMA delimited string
995  if ( strstr($_addrList, ',') )
996  // "explode "list" into an array
997  $_addrList = explode(',', $_addrList);
998 
999  // Stick it in an array
1000  else
1001  $_addrList = array($_addrList);
1002  }
1003 
1004  // take the array of addresses and split them further
1005  foreach ( $_addrList as $_strAddr )
1006  {
1007  // Strip off the end '>'
1008  $_strAddr = str_replace('>', '', $_strAddr);
1009 
1010  // Seperate "Real Name" from eMail address
1011  $_tmpaddr = null;
1012  $_tmpaddr = explode('<', $_strAddr);
1013 
1014  // We have a "Real Name" and eMail address
1015  if ( count($_tmpaddr) == 2 )
1016  {
1017  $_tmpHost = explode('@', $_tmpaddr[1]);
1018  $_tmpaddr[0] = trim($_tmpaddr[0], ' ">');
1019  $aryHost[$_tmpHost[1]][$_type][$_tmpHost[0]] = $_tmpaddr[0];
1020  }
1021  // We only have an eMail address
1022  else
1023  {
1024  // Strip off the beggining '<'
1025  $_strAddr = str_replace('<', '', $_strAddr);
1026 
1027  $_tmpHost = explode('@', $_strAddr);
1028  $_tmpHost[0] = trim($_tmpHost[0]);
1029  $_tmpHost[1] = trim($_tmpHost[1]);
1030 
1031  $aryHost[$_tmpHost[1]][$_type][$_tmpHost[0]] = '';
1032  }
1033  }
1034  }
1035  // replace list
1036  $this->_msgRecipients = $aryHost;
1037  }
1038 
1055  function _strip_email($_strAddr)
1056  {
1057  // Keep the orginal
1058  $_aryEmail['org'] = $_strAddr;
1059 
1060  // Set entire string to Lower Case
1061  $_strAddr = strtolower($_strAddr);
1062 
1063  // Drop "stuff' off the end
1064  $_strAddr = trim($_strAddr, ' ">');
1065 
1066  // Seperate "Real Name" from eMail address, if we have one
1067  $_tmpAry = explode('<', $_strAddr);
1068 
1069  // Do we have a "Real name"
1070  if ( count($_tmpAry) == 2 )
1071  {
1072  // We may not really have a "Real Name"
1073  if ( $_tmpAry[0])
1074  $_aryEmail['real'] = trim($_tmpAry[0], ' ">');
1075 
1076  $_aryEmail['addr'] = $_tmpAry[1];
1077  }
1078  else
1079  $_aryEmail['addr'] = $_tmpAry[0];
1080 
1081  // Pull User Name and Host.tld apart
1082  list($_aryEmail['user'], $_aryEmail['host'] ) = explode('@', $_aryEmail['addr']);
1083 
1084  // Put the brackets back around the address
1085  $_aryEmail['addr'] = '<' . $_aryEmail['addr'] . '>';
1086 
1087  return $_aryEmail;
1088  }
1089 
1097  function get_RCPT_list()
1098  {
1102  $_RCPT_list=array();
1103 
1104  // walk down Recipients array and pull just email addresses
1105  foreach ( $this->_msgRecipients as $_host => $_list )
1106  {
1107  foreach ( $_list as $_subList )
1108  {
1109  foreach ( $_subList as $_name => $_addr )
1110  {
1111  // build RCPT list
1112  $_RCPT_list[] = $_name . '@' . $_host;
1113  }
1114  }
1115  }
1116 
1117  return $_RCPT_list;
1118  }
1119 
1126  function get_email_list($_which = null)
1127  {
1128  // We need to know which address segment to pull
1129  if ( $_which )
1130  {
1131  // Make sure we have addresses to process
1132  if ( $this->_msgRecipients )
1133  {
1134  $_RCPT_list=array();
1135  // walk down Recipients array and pull just email addresses
1136  foreach ( $this->_msgRecipients as $_host => $_list )
1137  {
1138  if ( $this->_msgRecipients[$_host][$_which] )
1139  {
1140  foreach ( $this->_msgRecipients[$_host][$_which] as $_addr => $_realName )
1141  {
1142  if ( $_realName ) // @CHANGE LDR
1143  {
1144  $_realName = '"' . $_realName . '"';
1145  $_RCPT_list[] = $_realName . ' <' . $_addr . '@' . $_host . '>';
1146  }
1147  else
1148  {
1149  $_RCPT_list[] = $_addr . '@' . $_host;
1150  }
1151  }
1152  }
1153  }
1154 
1155  return implode(', ', $_RCPT_list);
1156  }
1157  else
1158  {
1159  $this->_setErr(101, 'No eMail Address for message to be sent to.');
1160  return false;
1161  }
1162  }
1163  else
1164  {
1165  $this->_setErr(102, 'eMail type not defined.');
1166  return false;
1167  }
1168 
1169  }
1170 
1177  function setTO($_addrTo)
1178  {
1179  if ( $_addrTo )
1180  $this->_buildAddrList('to', $_addrTo);
1181  }
1182 
1188  function getTo()
1189  {
1190  return $this->get_email_list('to');
1191  }
1192 
1199  function setCC($_strCC)
1200  {
1201  if ( $_strCC )
1202  $this->_buildAddrList('cc', $_strCC);
1203  }
1204 
1210  function getCC()
1211  {
1212  return $this->get_email_list('cc');
1213  }
1214 
1221  function setBCC($_strBCC)
1222  {
1223  if ( $_strBCC )
1224  $this->_buildAddrList('bcc', $_strBCC);
1225  }
1226 
1232  function getBCC()
1233  {
1234  return $this->get_email_list('bcc');
1235  }
1236 
1243  function setSubject($_strSubject = '')
1244  {
1245  if ( $_strSubject )
1246  $this->_msgSubject = $_strSubject;
1247  }
1248 
1254  function getSubject()
1255  {
1256  return $this->_msgSubject;
1257  }
1258 
1264  function getHeader()
1265  {
1266  global $conf;
1267 
1268  $_header = 'From: ' . $this->getFrom('org') . "\r\n"
1269  . 'To: ' . $this->getTO() . "\r\n";
1270 
1271  if ( $this->getCC() )
1272  $_header .= 'Cc: ' . $this->getCC() . "\r\n";
1273 
1274  /* Note:
1275  * BCC email addresses must be listed in the RCPT TO command list,
1276  * but the BCC header should not be printed under the DATA command.
1277  * So it is included into the function sendMsg() but not here.
1278  * http://stackoverflow.com/questions/2750211/sending-bcc-emails-using-a-smtp-server
1279  */
1280  /*
1281  if ( $this->getBCC() )
1282  $_header .= 'Bcc: ' . $this->getBCC() . "\r\n";
1283  */
1284 
1285  $host=$this->getHost();
1286  $usetls = preg_match('@tls://@i',$host);
1287 
1288  $host=preg_replace('@tcp://@i','',$host); // Remove prefix
1289  $host=preg_replace('@ssl://@i','',$host); // Remove prefix
1290  $host=preg_replace('@tls://@i','',$host); // Remove prefix
1291 
1292  $host=dol_getprefix('email');
1293 
1294  //NOTE: Message-ID should probably contain the username of the user who sent the msg
1295  $_header .= 'Subject: ' . $this->getSubject() . "\r\n";
1296  $_header .= 'Date: ' . date("r") . "\r\n";
1297 
1298  $trackid = $this->getTrackId();
1299  if ($trackid)
1300  {
1301  // References is kept in response and Message-ID is returned into In-Reply-To:
1302  $_header .= 'Message-ID: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n";
1303  $_header .= 'References: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n";
1304  $_header .= 'X-Dolibarr-TRACKID: ' . $trackid . "\r\n";
1305  }
1306  else
1307  {
1308  $_header .= 'Message-ID: <' . time() . '.SMTPs@' . $host . ">\r\n";
1309  }
1310  if (! empty($_SERVER['REMOTE_ADDR'])) $_header .= "X-RemoteAddr: " . $_SERVER['REMOTE_ADDR']. "\r\n";
1311  if ( $this->getMoreInHeader() )
1312  $_header .= $this->getMoreInHeader(); // Value must include the "\r\n";
1313 
1314  //$_header .=
1315  // 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"
1316  // 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n";
1317 
1318  if ( $this->getSensitivity() )
1319  $_header .= 'Sensitivity: ' . $this->getSensitivity() . "\r\n";
1320 
1321  if ( $this->_msgPriority != 3 )
1322  $_header .= $this->getPriority();
1323 
1324 
1325  // @CHANGE LDR
1326  if ( $this->getDeliveryReceipt() )
1327  $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n";
1328  if ( $this->getErrorsTo() )
1329  $_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n";
1330  if ( $this->getReplyTo() )
1331  $_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n";
1332 
1333  $_header .= 'X-Mailer: Dolibarr version ' . DOL_VERSION .' (using SMTPs Mailer)' . "\r\n";
1334  $_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART?'MAIN_MAIL_USE_MULTI_PART':'No MAIN_MAIL_USE_MULTI_PART') . "\r\n";
1335  $_header .= 'Mime-Version: 1.0' . "\r\n";
1336 
1337 
1338  return $_header;
1339  }
1340 
1348  function setBodyContent($strContent, $strType = 'plain')
1349  {
1350  //if ( $strContent )
1351  //{
1352  if ( $strType == 'html' )
1353  $strMimeType = 'text/html';
1354  else
1355  $strMimeType = 'text/plain';
1356 
1357  // Make RFC821 Compliant, replace bare linefeeds
1358  $strContent = preg_replace("/(?<!\r)\n/si", "\r\n", $strContent);
1359 
1360  $strContentAltText = '';
1361  if ($strType == 'html')
1362  {
1363  $strContentAltText = html_entity_decode(strip_tags($strContent));
1364  $strContentAltText = rtrim(wordwrap($strContentAltText, 75, "\r\n"));
1365  }
1366 
1367  // Make RFC2045 Compliant
1368  //$strContent = rtrim(chunk_split($strContent)); // Function chunck_split seems ko if not used on a base64 content
1369  $strContent = rtrim(wordwrap($strContent, 75, "\r\n")); // TODO Using this method creates unexpected line break on text/plain content.
1370 
1371  $this->_msgContent[$strType] = array();
1372 
1373  $this->_msgContent[$strType]['mimeType'] = $strMimeType;
1374  $this->_msgContent[$strType]['data'] = $strContent;
1375  $this->_msgContent[$strType]['dataText'] = $strContentAltText;
1376 
1377  if ( $this->getMD5flag() )
1378  $this->_msgContent[$strType]['md5'] = dol_hash($strContent, 3);
1379  //}
1380  }
1381 
1387  function getBodyContent()
1388  {
1389  global $conf;
1390 
1391  // Generate a new Boundary string
1392  $this->_setBoundary();
1393 
1394  // What type[s] of content do we have
1395  $_types = array_keys($this->_msgContent);
1396 
1397  // How many content types do we have
1398  $keyCount = count($_types);
1399 
1400  // If we have ZERO, we have a problem
1401  if( $keyCount === 0 )
1402  die ("Sorry, no content");
1403 
1404  // If we have ONE, we can use the simple format
1405  else if( $keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART))
1406  {
1407  $_msgData = $this->_msgContent;
1408  $_msgData = $_msgData[$_types[0]];
1409 
1410  $content = 'Content-Type: ' . $_msgData['mimeType'] . '; charset="' . $this->getCharSet() . '"' . "\r\n"
1411  . 'Content-Transfer-Encoding: ' . $this->getTransEncodeType() . "\r\n"
1412  . 'Content-Disposition: inline' . "\r\n"
1413  . 'Content-Description: message' . "\r\n";
1414 
1415  if ( $this->getMD5flag() )
1416  $content .= 'Content-MD5: ' . $_msgData['md5'] . "\r\n";
1417 
1418  $content .= "\r\n"
1419  . $_msgData['data'] . "\r\n";
1420  }
1421 
1422  // If we have more than ONE, we use the multi-part format
1423  else if( $keyCount >= 1 || ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART))
1424  {
1425  // Since this is an actual multi-part message
1426  // We need to define a content message Boundary
1427  // NOTE: This was 'multipart/alternative', but Windows based mail servers have issues with this.
1428 
1429  //$content = 'Content-Type: multipart/related; boundary="' . $this->_getBoundary() . '"' . "\r\n";
1430  $content = 'Content-Type: multipart/mixed; boundary="' . $this->_getBoundary('mixed') . '"' . "\r\n";
1431 
1432  // . "\r\n"
1433  // . 'This is a multi-part message in MIME format.' . "\r\n";
1434  $content .= "Content-Transfer-Encoding: 8bit\r\n";
1435  $content .= "\r\n";
1436 
1437  $content .= "--" . $this->_getBoundary('mixed') . "\r\n";
1438 
1439  if (key_exists('image', $this->_msgContent)) // If inline image found
1440  {
1441  $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n";
1442  $content .= "\r\n";
1443  $content .= "--" . $this->_getBoundary('alternative') . "\r\n";
1444  }
1445 
1446 
1447  // $this->_msgContent must be sorted with key 'text' or 'html' first then 'image' then 'attachment'
1448 
1449 
1450  // Loop through message content array
1451  foreach ($this->_msgContent as $type => $_content )
1452  {
1453  if ( $type == 'attachment' )
1454  {
1455  // loop through all attachments
1456  foreach ( $_content as $_file => $_data )
1457  {
1458  $content .= "--" . $this->_getBoundary('mixed') . "\r\n"
1459  . 'Content-Disposition: attachment; filename="' . $_data['fileName'] . '"' . "\r\n"
1460  . 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['fileName'] . '"' . "\r\n"
1461  . 'Content-Transfer-Encoding: base64' . "\r\n"
1462  . 'Content-Description: File Attachment' . "\r\n";
1463 
1464  if ( $this->getMD5flag() )
1465  $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n";
1466 
1467  $content .= "\r\n" . $_data['data'] . "\r\n\r\n";
1468  }
1469  }
1470  // @CHANGE LDR
1471  else if ( $type == 'image' )
1472  {
1473  // loop through all images
1474  foreach ( $_content as $_image => $_data )
1475  {
1476  $content .= "--" . $this->_getBoundary('related') . "\r\n"; // always related for an inline image
1477 
1478  $content .= 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['imageName'] . '"' . "\r\n"
1479  . 'Content-Transfer-Encoding: base64' . "\r\n"
1480  . 'Content-Disposition: inline; filename="' . $_data['imageName'] . '"' . "\r\n"
1481  . 'Content-ID: <' . $_data['cid'] . '> ' . "\r\n";
1482 
1483  if ( $this->getMD5flag() )
1484  $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n";
1485 
1486  $content .= "\r\n"
1487  . $_data['data'] . "\r\n";
1488  }
1489 
1490  // always end related and end alternative after inline images
1491  $content.= "--" . $this->_getBoundary('related') . "--" . "\r\n";
1492  $content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n";
1493  $content.= "\r\n";
1494  }
1495  else
1496  {
1497  if (key_exists('image', $this->_msgContent))
1498  {
1499  $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n";
1500  $content.= "\r\n" . ($_content['dataText']?$_content['dataText']:strip_tags($_content['data'])) . "\r\n"; // Add plain text message
1501  $content.= "--" . $this->_getBoundary('alternative') . "\r\n";
1502  $content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n";
1503  $content.= "\r\n";
1504  $content.= "--" . $this->_getBoundary('related') . "\r\n";
1505  }
1506 
1507  if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part
1508  {
1509  $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n";
1510  $content .= "\r\n";
1511  $content .= "--" . $this->_getBoundary('alternative') . "\r\n";
1512 
1513  $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n";
1514  $content.= "\r\n". $_content['dataText'] . "\r\n";
1515  $content.= "--" . $this->_getBoundary('alternative') . "\r\n";
1516  }
1517 
1518  $content .= 'Content-Type: ' . $_content['mimeType'] . '; '
1519  // . 'charset="' . $this->getCharSet() . '"';
1520  . 'charset=' . $this->getCharSet() . '';
1521 
1522  // $content .= ( $type == 'html') ? '; name="HTML Part"' : '';
1523  $content .= "\r\n";
1524  // $content .= 'Content-Transfer-Encoding: ';
1525  // $content .= ($type == 'html') ? 'quoted-printable' : $this->getTransEncodeType();
1526  // $content .= "\r\n"
1527  // . 'Content-Disposition: inline' . "\r\n"
1528  // . 'Content-Description: ' . $type . ' message' . "\r\n";
1529 
1530  if ( $this->getMD5flag() )
1531  $content .= 'Content-MD5: ' . $_content['md5'] . "\r\n";
1532 
1533  $content .= "\r\n" . $_content['data'] . "\r\n";
1534 
1535  if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part after html part
1536  {
1537  $content.= "--" . $this->_getBoundary('alternative') . "--". "\r\n";
1538  }
1539 
1540  $content .= "\r\n";
1541  }
1542  }
1543 
1544  // Close message boundries
1545  // $content .= "\r\n--" . $this->_getBoundary() . '--' . "\r\n" ;
1546  $content .= "--" . $this->_getBoundary('mixed') . '--' . "\r\n" ;
1547  }
1548 
1549  return $content;
1550  }
1551 
1561  function setAttachment($strContent, $strFileName = 'unknown', $strMimeType = 'unknown')
1562  {
1563  if ( $strContent )
1564  {
1565  $strContent = rtrim(chunk_split(base64_encode($strContent), 76, "\r\n")); // 76 max is defined into http://tools.ietf.org/html/rfc2047
1566 
1567  $this->_msgContent['attachment'][$strFileName]['mimeType'] = $strMimeType;
1568  $this->_msgContent['attachment'][$strFileName]['fileName'] = $strFileName;
1569  $this->_msgContent['attachment'][$strFileName]['data'] = $strContent;
1570 
1571  if ( $this->getMD5flag() )
1572  $this->_msgContent['attachment'][$strFileName]['md5'] = dol_hash($strContent, 3);
1573  }
1574  }
1575 
1576 
1577  // @CHANGE LDR
1578 
1589  function setImageInline($strContent, $strImageName = 'unknown', $strMimeType = 'unknown', $strImageCid = 'unknown')
1590  {
1591  if ($strContent)
1592  {
1593  $this->_msgContent['image'][$strImageName]['mimeType'] = $strMimeType;
1594  $this->_msgContent['image'][$strImageName]['imageName'] = $strImageName;
1595  $this->_msgContent['image'][$strImageName]['cid'] = $strImageCid;
1596  $this->_msgContent['image'][$strImageName]['data'] = $strContent;
1597 
1598  if ( $this->getMD5flag() )
1599  $this->_msgContent['image'][$strImageName]['md5'] = dol_hash($strContent, 3);
1600  }
1601  }
1602  // END @CHANGE LDR
1603 
1604 
1616  function setSensitivity($_value = 0)
1617  {
1618  if ( ( is_numeric($_value) ) &&
1619  ( ( $_value >= 0 ) && ( $_value <= 3 ) ) )
1620  $this->_msgSensitivity = $_value;
1621  }
1622 
1633  function getSensitivity()
1634  {
1635  return $this->_arySensitivity[$this->_msgSensitivity];
1636  }
1637 
1651  function setPriority ( $_value = 3 )
1652  {
1653  if ( ( is_numeric($_value) ) &&
1654  ( ( $_value >= 0 ) && ( $_value <= 5 ) ) )
1655  $this->_msgPriority = $_value;
1656  }
1657 
1670  function getPriority()
1671  {
1672  return 'Importance: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n"
1673  . 'Priority: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n"
1674  . 'X-Priority: ' . $this->_msgPriority . ' (' . $this->_aryPriority[$this->_msgPriority] . ')' . "\r\n";
1675  }
1676 
1683  function setMD5flag($_flag = false)
1684  {
1685  $this->_smtpMD5 = $_flag;
1686  }
1687 
1693  function getMD5flag()
1694  {
1695  return $this->_smtpMD5;
1696  }
1697 
1706  function setXheader($strXdata)
1707  {
1708  if ( $strXdata )
1709  $this->_msgXheader[] = $strXdata;
1710  }
1711 
1717  function getXheader()
1718  {
1719  return $this->_msgXheader;
1720  }
1721 
1727  function _setBoundary()
1728  {
1729  $this->_smtpsBoundary = "multipart_x." . time() . ".x_boundary";
1730  $this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2"), 3);
1731  $this->_smtpsAlternativeBoundary = 'mul_'.dol_hash(uniqid("dolibarr3"), 3);
1732  }
1733 
1740  function _getBoundary($type='mixed')
1741  {
1742  if ($type == 'mixed') return $this->_smtpsBoundary;
1743  else if ($type == 'related') return $this->_smtpsRelatedBoundary;
1744  else if ($type == 'alternative') return $this->_smtpsAlternativeBoundary;
1745  }
1746 
1755  function server_parse($socket, $response)
1756  {
1761  $_retVal = true;
1762 
1763  $server_response = '';
1764 
1765  // avoid infinite loop
1766  $limit=0;
1767 
1768  while (substr($server_response,3,1) != ' ' && $limit<100)
1769  {
1770  if (! ($server_response = fgets($socket, 256)))
1771  {
1772  $this->_setErr(121, "Couldn't get mail server response codes");
1773  $_retVal = false;
1774  break;
1775  }
1776  $limit++;
1777  }
1778 
1779  if (! (substr($server_response, 0, 3) == $response))
1780  {
1781  $this->_setErr(120, "Ran into problems sending Mail.\r\nResponse: $server_response");
1782  $_retVal = false;
1783  }
1784 
1785  return $_retVal;
1786  }
1787 
1796  function socket_send_str( $_strSend, $_returnCode = null, $CRLF = "\r\n" )
1797  {
1798  if ($this->_debug) $this->log.=$_strSend; // @CHANGE LDR for log
1799  fputs($this->socket, $_strSend . $CRLF);
1800  if ($this->_debug) $this->log.=' ('.$_returnCode.')' . $CRLF;
1801 
1802  if ( $_returnCode )
1803  return $this->server_parse($this->socket, $_returnCode);
1804  }
1805 
1806  // =============================================================
1807  // ** Error handling methods
1808 
1816  function _setErr ( $_errNum, $_errMsg )
1817  {
1818  $this->_smtpsErrors[] = array( 'num' => $_errNum,
1819  'msg' => $_errMsg );
1820  }
1821 
1827  function getErrors()
1828  {
1829  $_errMsg = array();
1830 
1831  foreach ( $this->_smtpsErrors as $_err => $_info )
1832  {
1833  $_errMsg[] = 'Error [' . $_info['num'] .']: '. $_info['msg'];
1834  }
1835 
1836  return implode("\n", $_errMsg);
1837  }
1838 
1839 
1840 }
1841 
1842 
1843 // =============================================================
1844 // ** CSV Version Control Info
1845 
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.
setBodyContent($strContent, $strType= 'plain')
Message Content.
setTransEncodeType($_strTransEncodeType)
Content-Transfer-Encoding, Defaulted to '0' [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 'iso-8859-1';.
$_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.
$_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
setMoreInHeader($_val= '')
Set moreInHeader.
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.
setTrackId($_val= '')
Set trackid.
$_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
getMD5flag()
Gets flag which determines whether to calculate message MD5 checksum.
setTransEncode($_strTransEncode)
Content-Transfer-Encoding, Defaulted to '7bit' 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 'RCPT TO:' 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...
setCC($_strCC)
CC Address[es] inwhich to send mail to.
_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
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...
setPort($_intPort)
Defines the Port Number of the Mail Server to use This is defaulted to '25' This is used only with 's...
getBCC()
Retrieves the BCC Address[es] inwhich to send mail to.
$_smtpsHost
Host Name or IP of SMTP Server to use.
Definition: smtps.class.php:51
$_smtpsAlternativeBoundary
Alternative Boundary.
socket_send_str($_strSend, $_returnCode=null, $CRLF="\r\n")
Send str.
$_smtpsTransEncode
Content-Transfer-Encoding Defaulted to '7bit'.
setAttachment($strContent, $strFileName= 'unknown', $strMimeType= 'unknown')
File attachments are added to the content array as sub-arrays, allowing for multiple attachments for ...
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 'socket' 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 'socket' 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 'iso-8859-1'.
$_smtpsErrors
Class error codes and messages.
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.
setSubject($_strSubject= '')
Message Subject.
$_mailPath
If '$_transportType' is set to '1', 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.
_setErr($_errNum, $_errMsg)
Defines errors codes and messages for Class.
setPriority($_value=3)
Message Content Priority Message Priority values:
setMD5flag($_flag=false)
Set flag which determines whether to calculate message MD5 checksum.