53 private $_smtpsHost =
'localhost';
61 private $_smtpsPort = 25;
67 private $_smtpsID =
null;
73 private $_smtpsPW =
null;
78 private $_smtpsToken =
null;
83 private $_msgId =
null;
89 private $_msgFrom =
null;
95 private $_msgReplyTo =
null;
100 private $_msgInReplyTo =
null;
105 private $_msgReferences =
null;
112 private $_msgRecipients =
null;
117 private $_msgSubject =
null;
124 private $_msgContent = array();
129 private $_msgXheader = array();
136 private $_smtpsCharSet =
'iso-8859-1';
143 private $_msgSensitivity = 0;
148 private $_arySensitivity = array(
false,
151 'Company Confidential');
157 private $_msgPriority = 3;
162 private $_aryPriority = array(
'Bulk',
173 private $_smtpsTransEncodeType = 0;
178 private $_smtpsTransEncodeTypes = array(
'7bit',
191 private $_smtpsTransEncode =
'7bit';
196 private $_smtpsBoundary =
null;
201 private $_smtpsRelatedBoundary =
null;
206 private $_smtpsAlternativeBoundary =
null;
216 private $_transportType = 0;
222 private $_mailPath =
'/usr/lib/sendmail';
227 private $_smtpTimeout = 10;
232 private $_smtpMD5 =
false;
237 private $_smtpsErrors = array();
246 private $_log_level = 0;
251 private $_debug =
false;
262 public $lastretval =
'';
282 private $_errorsTo = array();
286 private $_deliveryReceipt = 0;
290 private $_trackId =
'';
294 private $_moreinheader =
'';
299 private $_options = array();
310 $this->_msgId = $_msgId;
321 $this->_options = $_options;
332 $this->_deliveryReceipt = $_val;
342 return $this->_deliveryReceipt;
353 $this->_smtpTimeout = $timeout;
363 return $this->_smtpTimeout;
374 $this->_trackId = $_val;
385 $this->_moreinheader = $_val;
395 return $this->_trackId;
405 return $this->_moreinheader;
431 if ($_part ===
true || !array_key_exists($_part, $this->_errorsTo)) {
432 $_retValue = $this->_errorsTo;
434 $_retValue = $this->_errorsTo[$_part];
448 $this->_debug = $_vDebug;
459 $_aryToList = $this->
getTo();
478 $usetls = preg_match(
'@tls://@i', $host);
480 $host = preg_replace(
'@tcp://@i',
'', $host);
481 $host = preg_replace(
'@ssl://@i',
'', $host);
482 $host = preg_replace(
'@tls://@i',
'', $host);
485 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
487 if ((!
is_ip($host)) && ((gethostbyname($host)) == $host)) {
488 $this->
_setErr(99, $host.
' is either offline or is an invalid host name.');
491 if (function_exists(
'stream_socket_client') && !empty($this->_options)) {
492 $socket_context = stream_context_create($this->_options);
493 $this->socket = @stream_socket_client(
494 preg_replace(
'@tls://@i',
'', $this->
getHost()).
499 STREAM_CLIENT_CONNECT,
503 $this->socket = @fsockopen(
504 preg_replace(
'@tls://@i',
'', $this->
getHost()),
513 if (is_resource($this->socket)) {
518 if (function_exists(
'stream_set_timeout')) {
519 stream_set_timeout($this->socket, $this->_smtpTimeout, 0);
523 if ($_retVal = $this->
server_parse($this->socket,
"220")) {
524 $_retVal = $this->socket;
529 if (empty($this->errstr)) {
530 $this->errstr =
'Failed to connect with stream_context_create or fsockopen host='.$this->getHost().
' port='.$this->
getPort();
532 $this->
_setErr($this->errno, $this->errstr);
551 require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
556 $usetls = preg_match(
'@tls://@i', $host);
558 $host = preg_replace(
'@tcp://@i',
'', $host);
559 $host = preg_replace(
'@ssl://@i',
'', $host);
560 $host = preg_replace(
'@tls://@i',
'', $host);
563 $host =
'tls://'.$host;
576 $hosth = preg_replace(
'/^.*</',
'', $hosth);
577 $hosth = preg_replace(
'/>.*$/',
'', $hosth);
578 $hosth = preg_replace(
'/.*@/',
'', $hosth);
641 $this->
_setErr(131,
'STARTTLS connection is not supported.');
652 $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT;
653 if (defined(
'STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) {
654 $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
655 $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
658 if (!stream_socket_enable_crypto($this->socket,
true, $crypto_method)) {
659 $this->
_setErr(132,
'STARTTLS connection failed.');
665 $this->
_setErr(126,
'"'.$hosth.
'" does not support authenticated connections or temporary error. Error after 2nd sending EHLO '.$hosth.
' : '.$this->lastretval);
672 $conf->global->MAIN_MAIL_SMTPS_AUTH_TYPE =
'LOGIN';
677 switch (
$conf->global->MAIN_MAIL_SMTPS_AUTH_TYPE) {
685 $_retVal = $this->
socket_send_str(base64_encode(
"\0".$this->_smtpsID.
"\0".$this->_smtpsPW),
'235');
689 $user = $this->_smtpsID;
690 $token = $this->_smtpsToken;
691 $initRes =
"user=".$user.
"\001auth=Bearer ".$token.
"\001\001";
692 $_retVal = $this->
socket_send_str(
'AUTH XOAUTH2 '.base64_encode($initRes),
'235');
694 $this->
_setErr(130,
'Error when asking for AUTH XOAUTH2');
701 $this->
_setErr(130,
'Error when asking for AUTH LOGIN');
704 $this->
socket_send_str(base64_encode((
string) $this->_smtpsID),
'334');
707 $_retVal = $this->
socket_send_str(base64_encode((
string) $this->_smtpsPW),
'235');
712 $this->
_setErr(130,
'Invalid Authentication Credentials.');
715 $this->
_setErr(126,
'"'.$host.
'" refused the EHLO command. Error after sending EHLO '.$hosth.
' : '.$this->lastretval);
728 require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
736 if (!empty($this->_smtpsID) && (!empty($this->_smtpsPW) || !empty($this->_smtpsToken))) {
743 $usetls = preg_match(
'@tls://@i', $host);
745 $host = preg_replace(
'@tcp://@i',
'', $host);
746 $host = preg_replace(
'@ssl://@i',
'', $host);
747 $host = preg_replace(
'@tls://@i',
'', $host);
750 $host =
'tls://'.$host;
763 $hosth = preg_replace(
'/^.*</',
'', $hosth);
764 $hosth = preg_replace(
'/>.*$/',
'', $hosth);
765 $hosth = preg_replace(
'/.*@/',
'', $hosth);
783 if (!$resultmailfrom) {
784 fclose($this->socket);
819 fwrite($this->socket,
'QUIT');
824 fclose($this->socket);
869 if (!empty($_strConfigPath)) {
872 if (!@include $_strConfigPath) {
873 $this->
_setErr(110,
'"'.$_strConfigPath.
'" is not a valid path.');
880 if ($_host = ini_get(
'SMTPs')) {
884 if ($_port = ini_get(
'smtp_port')) {
888 if ($_from = ini_get(
'sendmail_from')) {
908 if ((is_numeric($_type)) && (($_type >= 0) && ($_type <= 3))) {
909 $this->_transportType = $_type;
923 return $this->_transportType;
951 $this->_smtpsHost = $_strHost;
963 return $this->_smtpsHost;
976 if ((is_numeric($_intPort)) &&
977 (($_intPort >= 1) && ($_intPort <= 65536))) {
978 $this->_smtpsPort = (int) $_intPort;
990 return (
int) $this->_smtpsPort;
1001 $this->_smtpsID = $_strID;
1011 return $this->_smtpsID;
1022 $this->_smtpsPW = $_strPW;
1032 return $this->_smtpsPW;
1043 $this->_smtpsToken = $_strToken;
1053 return $this->_smtpsToken;
1066 $this->_smtpsCharSet = $_strCharSet;
1077 return $this->_smtpsCharSet;
1097 if (array_search($_strTransEncode, $this->_smtpsTransEncodeTypes)) {
1098 $this->_smtpsTransEncode = $_strTransEncode;
1109 return $this->_smtpsTransEncode;
1129 if (array_search($_strTransEncodeType, $this->_smtpsTransEncodeTypes)) {
1130 $this->_smtpsTransEncodeType = $_strTransEncodeType;
1141 return $this->_smtpsTransEncodeTypes[$this->_smtpsTransEncodeType];
1170 if ($_part ===
true || $this->_msgFrom ===
null) {
1171 $_retValue = $this->_msgFrom;
1173 $_retValue = $this->_msgFrom[$_part];
1188 $this->_msgReplyTo = $this->
_strip_email($_strReplyTo);
1202 if ($_part ===
true) {
1203 $_retValue = $this->_msgReplyTo;
1205 $_retValue = $this->_msgReplyTo[$_part];
1219 if ($_strInReplyTo) {
1220 $this->_msgInReplyTo = $_strInReplyTo;
1231 $_retValue = $this->_msgInReplyTo;
1244 if ($_strReferences) {
1245 $this->_msgReferences = $_strReferences;
1256 $_retValue = $this->_msgReferences;
1273 $aryHost = $this->_msgRecipients;
1276 if (!empty($_addrList)) {
1278 if (is_string($_addrList)) {
1280 if (strstr($_addrList,
',')) {
1282 $_addrList = explode(
',', $_addrList);
1285 $_addrList = array($_addrList);
1290 foreach ($_addrList as $_strAddr) {
1292 $_strAddr = str_replace(
'>',
'', $_strAddr);
1296 $_tmpaddr = explode(
'<', $_strAddr);
1299 if (count($_tmpaddr) == 2) {
1300 $_tmpHost = explode(
'@', $_tmpaddr[1]);
1301 $_tmpaddr[0] = trim($_tmpaddr[0],
' ">');
1302 $aryHost[$_tmpHost[1]][$_type][$_tmpHost[0]] = $_tmpaddr[0];
1306 $_strAddr = str_replace(
'<',
'', $_strAddr);
1308 $_tmpHost = explode(
'@', $_strAddr);
1309 $_tmpHost[0] = trim($_tmpHost[0]);
1310 $_tmpHost[1] = trim($_tmpHost[1]);
1312 $aryHost[$_tmpHost[1]][$_type][$_tmpHost[0]] =
'';
1317 $this->_msgRecipients = $aryHost;
1340 $_aryEmail = array();
1342 $_aryEmail[
'org'] = $_strAddr;
1345 $_strAddr = strtolower($_strAddr);
1348 $_strAddr = trim($_strAddr,
' ">');
1351 $_tmpAry = explode(
'<', $_strAddr);
1354 if (count($_tmpAry) == 2) {
1357 $_aryEmail[
'real'] = trim($_tmpAry[0],
' ">');
1360 $_aryEmail[
'addr'] = $_tmpAry[1];
1362 $_aryEmail[
'addr'] = $_tmpAry[0];
1366 $_tmpHost = explode(
'@', $_aryEmail[
'addr']);
1367 $_aryEmail[
'user'] = $_tmpHost[0];
1368 $_aryEmail[
'host'] = $_tmpHost[1];
1371 $_aryEmail[
'addr'] =
'<'.$_aryEmail[
'addr'].
'>';
1390 $_RCPT_list = array();
1393 foreach ($this->_msgRecipients as $_host => $_list) {
1394 foreach ($_list as $_subList) {
1395 foreach ($_subList as $_name => $_addr) {
1397 $_RCPT_list[] = $_name.
'@'.$_host;
1418 if ($this->_msgRecipients) {
1419 $_RCPT_list = array();
1421 foreach ($this->_msgRecipients as $_host => $_list) {
1422 if (!empty($this->_msgRecipients[$_host][$_which])) {
1423 foreach ($this->_msgRecipients[$_host][$_which] as $_addr => $_realName) {
1425 $_realName =
'"'.$_realName.
'"';
1426 $_RCPT_list[] = $_realName.
' <'.$_addr.
'@'.$_host.
'>';
1428 $_RCPT_list[] = $_addr.
'@'.$_host;
1434 return implode(
', ', $_RCPT_list);
1436 $this->
_setErr(101,
'No eMail Address for message to be sent to.');
1440 $this->
_setErr(102,
'eMail type not defined.');
1523 $this->_msgSubject = $_strSubject;
1534 return $this->_msgSubject;
1546 $_header =
'From: '.$this->getFrom(
'org').
"\r\n"
1547 .
'To: '.$this->getTo().
"\r\n";
1549 if ($this->
getCC()) {
1550 $_header .=
'Cc: '.$this->getCC().
"\r\n";
1564 $host = dol_getprefix(
'email');
1566 $_header .=
'Subject: '.$this->getSubject().
"\r\n";
1567 $_header .=
'Date: '.date(
"r").
"\r\n";
1571 $_header .=
'Message-ID: <'.(empty($this->_msgId) ? uniqid().
'.SMTPs-dolibarr-'.$trackid.
'@'.$host : $this->_msgId).
">\r\n";
1572 $_header .=
'X-Dolibarr-TRACKID: '.$trackid.
'@'.$host.
"\r\n";
1574 $_header .=
'Message-ID: <'.(empty($this->_msgId) ? uniqid().
'.SMTPs@'.$host : $this->_msgId).
">\r\n";
1576 if (!empty($_SERVER[
'REMOTE_ADDR'])) {
1577 $_header .=
"X-RemoteAddr: ".$_SERVER[
'REMOTE_ADDR'].
"\r\n";
1584 $_header .=
'Sensitivity: '.$this->getSensitivity().
"\r\n";
1587 if ($this->_msgPriority != 3) {
1594 $_header .=
'Disposition-Notification-To: '.$this->getFrom(
'addr').
"\r\n";
1597 $_header .=
'Errors-To: '.$this->getErrorsTo(
'addr').
"\r\n";
1600 $_header .=
"Reply-To: ".$this->getReplyTo(
'addr').
"\r\n";
1603 $_header .=
'X-Mailer: Dolibarr version '.DOL_VERSION.
' (using SMTPs Mailer)'.
"\r\n";
1604 $_header .=
'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART ?
'MAIN_MAIL_USE_MULTI_PART' :
'No MAIN_MAIL_USE_MULTI_PART').
"\r\n";
1605 $_header .=
'Mime-Version: 1.0'.
"\r\n";
1609 $_header .=
"In-Reply-To: ".$this->getInReplyTo().
"\r\n";
1615 $_header .=
"References: ".implode(
' ', $references).
"\r\n";
1632 if ($strType ==
'html') {
1633 $strMimeType =
'text/html';
1635 $strMimeType =
'text/plain';
1639 $strContent = preg_replace(
"/(?<!\r)\n/si",
"\r\n", $strContent);
1641 $strContentAltText =
'';
1642 if ($strType ==
'html') {
1644 $strContentAltText = preg_replace(
'/<head><title>.*<\/style><\/head>/',
'', $strContent);
1645 $strContentAltText = preg_replace(
"/<br\s*[^>]*>/",
" ", $strContentAltText);
1646 $strContentAltText = html_entity_decode(strip_tags($strContentAltText));
1647 $strContentAltText = trim(wordwrap($strContentAltText, 75,
"\r\n"));
1652 $strContent = rtrim(wordwrap($strContent, 75,
"\r\n"));
1654 $this->_msgContent[$strType] = array();
1656 $this->_msgContent[$strType][
'mimeType'] = $strMimeType;
1657 $this->_msgContent[$strType][
'data'] = $strContent;
1658 $this->_msgContent[$strType][
'dataText'] = $strContentAltText;
1661 $this->_msgContent[$strType][
'md5'] =
dol_hash($strContent,
'3');
1679 $_types = array_keys($this->_msgContent);
1682 $keyCount = count($_types);
1685 if ($keyCount === 0) {
1686 die(
"Sorry, no content");
1689 $_msgData = $this->_msgContent;
1690 $_msgData = $_msgData[$_types[0]];
1692 $content =
'Content-Type: '.$_msgData[
'mimeType'].
'; charset="'.$this->
getCharSet().
'"'.
"\r\n"
1693 .
'Content-Transfer-Encoding: '.$this->getTransEncodeType().
"\r\n"
1694 .
'Content-Disposition: inline'.
"\r\n"
1695 .
'Content-Description: Message'.
"\r\n";
1698 $content .=
'Content-MD5: '.$_msgData[
'md5'].
"\r\n";
1702 . $_msgData[
'data'].
"\r\n";
1710 $content =
'Content-Type: multipart/mixed; boundary="'.$this->_getBoundary(
'mixed').
'"'.
"\r\n";
1714 $content .=
"Content-Transfer-Encoding: 8bit\r\n";
1717 $content .=
"--".$this->_getBoundary(
'mixed').
"\r\n";
1719 if (array_key_exists(
'image', $this->_msgContent)) {
1720 $content .=
'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary(
'alternative').
'"'.
"\r\n";
1722 $content .=
"--".$this->_getBoundary(
'alternative').
"\r\n";
1730 foreach ($this->_msgContent as $type => $_content) {
1731 if ($type ==
'attachment') {
1733 foreach ($_content as $_file => $_data) {
1734 $content .=
"--".$this->_getBoundary(
'mixed').
"\r\n"
1735 .
'Content-Disposition: attachment; filename="'.$_data[
'fileName'].
'"'.
"\r\n"
1736 .
'Content-Type: '.$_data[
'mimeType'].
'; name="'.$_data[
'fileName'].
'"'.
"\r\n"
1737 .
'Content-Transfer-Encoding: base64'.
"\r\n"
1738 .
'Content-Description: '.$_data[
'fileName'].
"\r\n";
1739 if (!empty($_data[
'cid'])) {
1740 $content .=
"X-Attachment-Id: ".$_data[
'cid'].
"\r\n";
1741 $content .=
"Content-ID: <".$_data[
'cid'].
">\r\n";
1744 $content .=
'Content-MD5: '.$_data[
'md5'].
"\r\n";
1747 $content .=
"\r\n".$_data[
'data'].
"\r\n\r\n";
1749 } elseif ($type ==
'image') {
1752 foreach ($_content as $_image => $_data) {
1753 $content .=
"--".$this->_getBoundary(
'related').
"\r\n";
1755 $content .=
'Content-Type: '.$_data[
'mimeType'].
'; name="'.$_data[
'imageName'].
'"'.
"\r\n"
1756 .
'Content-Transfer-Encoding: base64'.
"\r\n"
1757 .
'Content-Disposition: inline; filename="'.$_data[
'imageName'].
'"'.
"\r\n"
1758 .
'Content-ID: <'.$_data[
'cid'].
'> '.
"\r\n";
1761 $content .=
'Content-MD5: '.$_data[
'md5'].
"\r\n";
1765 . $_data[
'data'].
"\r\n";
1769 $content .=
"--".$this->_getBoundary(
'related').
"--\r\n";
1770 $content .=
"\r\n--".$this->_getBoundary(
'alternative').
"--\r\n";
1773 if (array_key_exists(
'image', $this->_msgContent)) {
1774 $content .=
"Content-Type: text/plain; charset=".$this->getCharSet().
"\r\n";
1775 $content .=
"\r\n".($_content[
'dataText'] ? $_content[
'dataText'] : strip_tags($_content[
'data'])).
"\r\n";
1776 $content .=
"--".$this->_getBoundary(
'alternative').
"\r\n";
1777 $content .=
'Content-Type: multipart/related; boundary="'.$this->_getBoundary(
'related').
'"'.
"\r\n";
1779 $content .=
"--".$this->_getBoundary(
'related').
"\r\n";
1782 if (!array_key_exists(
'image', $this->_msgContent) && $_content[
'dataText'] &&
getDolGlobalString(
'MAIN_MAIL_USE_MULTI_PART')) {
1784 $content .=
'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary(
'alternative').
'"'.
"\r\n";
1786 $content .=
"--".$this->_getBoundary(
'alternative').
"\r\n";
1788 $content .=
"Content-Type: text/plain; charset=".$this->getCharSet().
"\r\n";
1789 $content .=
"\r\n".$_content[
'dataText'].
"\r\n";
1790 $content .=
"--".$this->_getBoundary(
'alternative').
"\r\n";
1793 $content .=
'Content-Type: '.$_content[
'mimeType'].
'; charset='.$this->
getCharSet();
1798 $content .=
'Content-MD5: '.$_content[
'md5'].
"\r\n";
1801 $content .=
"\r\n".$_content[
'data'].
"\r\n";
1803 if (!array_key_exists(
'image', $this->_msgContent) && $_content[
'dataText'] &&
getDolGlobalString(
'MAIN_MAIL_USE_MULTI_PART')) {
1805 $content .=
"--".$this->_getBoundary(
'alternative').
"--\r\n";
1812 $content .=
"--".$this->_getBoundary(
'mixed').
'--'.
"\r\n";
1814 die(
"Sorry, no content");
1830 public function setAttachment($strContent, $strFileName =
'unknown', $strMimeType =
'unknown', $strCid =
'')
1833 $strContent = rtrim(chunk_split(base64_encode($strContent), 76,
"\r\n"));
1835 $this->_msgContent[
'attachment'][$strFileName][
'mimeType'] = $strMimeType;
1836 $this->_msgContent[
'attachment'][$strFileName][
'fileName'] = $strFileName;
1837 $this->_msgContent[
'attachment'][$strFileName][
'data'] = $strContent;
1838 $this->_msgContent[
'attachment'][$strFileName][
'cid'] = $strCid;
1841 $this->_msgContent[
'attachment'][$strFileName][
'md5'] =
dol_hash($strContent,
'3');
1859 public function setImageInline($strContent, $strImageName =
'unknown', $strMimeType =
'unknown', $strImageCid =
'unknown')
1862 $this->_msgContent[
'image'][$strImageName][
'mimeType'] = $strMimeType;
1863 $this->_msgContent[
'image'][$strImageName][
'imageName'] = $strImageName;
1864 $this->_msgContent[
'image'][$strImageName][
'data'] = $strContent;
1865 $this->_msgContent[
'image'][$strImageName][
'cid'] = $strImageCid;
1868 $this->_msgContent[
'image'][$strImageName][
'md5'] =
dol_hash($strContent,
'3');
1888 if ((is_numeric($_value)) &&
1889 (($_value >= 0) && ($_value <= 3))) {
1890 $this->_msgSensitivity = $_value;
1906 return $this->_arySensitivity[$this->_msgSensitivity];
1924 if ((is_numeric($_value)) &&
1925 (($_value >= 0) && ($_value <= 5))) {
1926 $this->_msgPriority = $_value;
1944 return 'Importance: '.$this->_aryPriority[$this->_msgPriority].
"\r\n"
1945 .
'Priority: '.$this->_aryPriority[$this->_msgPriority].
"\r\n"
1946 .
'X-Priority: '.$this->_msgPriority.
' ('.$this->_aryPriority[$this->_msgPriority].
')'.
"\r\n";
1957 $this->_smtpMD5 = $_flag;
1967 return $this->_smtpMD5;
1981 $this->_msgXheader[] = $strXdata;
1992 return $this->_msgXheader;
2002 $this->_smtpsBoundary =
"multipart_x.".time().
".x_boundary";
2003 $this->_smtpsRelatedBoundary =
'mul_'.dol_hash(uniqid(
"dolibarr2"),
'3');
2004 $this->_smtpsAlternativeBoundary =
'mul_'.dol_hash(uniqid(
"dolibarr3"),
'3');
2015 if ($type ==
'mixed') {
2016 return $this->_smtpsBoundary;
2017 } elseif ($type ==
'related') {
2018 return $this->_smtpsRelatedBoundary;
2019 } elseif ($type ==
'alternative') {
2020 return $this->_smtpsAlternativeBoundary;
2045 $server_response =
'';
2050 while (substr($server_response, 3, 1) !=
' ' && $limit < 100) {
2051 if (!($server_response = fgets($socket, 256))) {
2052 $this->
_setErr(121,
"Couldn't get mail server response codes");
2056 $this->log .= $server_response;
2060 $this->lastretval = substr($server_response, 0, 3);
2062 if (!(substr($server_response, 0, 3) == $response)) {
2063 $this->
_setErr(120,
"Ran into problems sending Mail.\r\nResponse: ".$server_response);
2082 if ($this->_debug) {
2083 $this->log .= $_strSend;
2085 fwrite($this->socket, $_strSend.$CRLF);
2086 if ($this->_debug) {
2087 $this->log .=
' ('.$_returnCode.
')'.$CRLF;
2091 return $this->
server_parse($this->socket, $_returnCode);
2109 $this->_smtpsErrors[] = array(
2124 if (is_array($this->_smtpsErrors)) {
2125 foreach ($this->_smtpsErrors as $_err => $_info) {
2126 $_errMsg[] =
'Error ['.$_info[
'num'].
']: '.$_info[
'msg'];
2130 return implode(
"\n", $_errMsg);
global $dolibarr_main_url_root
Class to construct and send SMTP compliant email, even to a secure SMTP server, regardless of platfor...
_getBoundary($type='mixed')
Retrieves the MIME message Boundary.
setConfig($_strConfigPath=null)
setConfig() is used to populate select class properties from either a user defined INI file or the sy...
sendMsg()
Now send the message.
getErrors()
Returns applicative errors codes and messages for Class (not the SMTP error code)
setCharSet($_strCharSet)
Character set used for current message Character set is defaulted to 'iso-8859-1';.
setSubject($_strSubject='')
Message Subject.
getPriority()
Message Content Priority Message Priority values:
setReferences($_strReferences)
Set References in the list of Msg-Id.
getMD5flag()
Gets flag which determines whether to calculate message MD5 checksum.
socket_send_str($_strSend, $_returnCode=null, $CRLF="\r\n")
Send str.
_strip_email($_strAddr)
Returns an array of the various parts of an email address This assumes a well formed address:
getTransEncodeType()
Retrieves the Content-Transfer-Encoding.
setTrackId($_val='')
Set trackid.
setToken($_strToken)
User token for OAUTH2.
setInReplyTo($_strInReplyTo)
Set References in the list of Msg-Id.
buildRCPTlist()
build RECIPIENT List, all addresses who will receive this message
getBodyContent()
Retrieves the Message Content.
_buildAddrList($_type, $_addrList)
Inserts given addresses into structured format.
getInReplyTo()
Retrieves the InReplyTo from which mail we reply to.
setOptions($_options=array())
Set options.
_server_connect()
Attempt a connection to mail server.
setBodyContent($strContent, $strType='plain')
Message Content.
server_parse($socket, $response)
This function has been modified as provided by SirSir to allow multiline responses when using SMTP Ex...
setTransportType($_type=0)
Determines the method inwhich the messages are to be sent.
getBCC()
Retrieves the BCC Address[es] inwhich to send mail to.
setAttachment($strContent, $strFileName='unknown', $strMimeType='unknown', $strCid='')
File attachments are added to the content array as sub-arrays, allowing for multiple attachments for ...
_setBoundary()
Generates Random string for MIME message Boundary.
getTo()
Retrieves the TO Address[es] inwhich to send mail to.
setPort($_intPort)
Defines the Port Number of the Mail Server to use The default is 25 This is used only with 'socket' b...
getID()
Retrieves the User Name for authentication on Mail Server.
setBCC($_strBCC)
BCC Address[es] inwhich to send mail to.
setReplyTo($_strReplyTo)
Reply-To Address from which mail will be the reply-to.
getToken()
Retrieves the User token for OAUTH2.
setSensitivity($_value=0)
Message Content Sensitivity Message Sensitivity values:
setCC($_strCC)
CC Address[es] inwhich to send mail to.
getSMTPTimeout()
Get socket timeout.
setTO($_addrTo)
TO Address[es] inwhich to send mail to.
setTransEncodeType($_strTransEncodeType)
Content-Transfer-Encoding, Defaulted to '0' [ZERO] This can be changed for 2byte characters sets Know...
get_email_list($_which=null)
Returns an array of addresses for a specific type; TO, CC or BCC.
setMD5flag($_flag=false)
Set flag which determines whether to calculate message MD5 checksum.
getCharSet()
Retrieves the Character set used for current message.
getCC()
Retrieves the CC Address[es] inwhich to send mail to.
getDeliveryReceipt()
get delivery receipt
setFrom($_strFrom)
FROM Address from which mail will be sent.
get_RCPT_list()
Returns an array of bare addresses for use with 'RCPT TO:' This is a "build as you go" method.
_server_authenticate()
Attempt mail server authentication for a secure connection.
setID($_strID)
User Name for authentication on Mail Server.
getMoreInHeader()
get moreInHeader
getPW()
Retrieves the User Password for authentication on Mail Server.
getSubject()
Retrieves the Message Subject.
getXheader()
Retrieves the Message X-Header Content.
setErrorsTo($_strErrorsTo)
Set errors 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...
setMessageID($_msgId='')
Set Message-ID.
setHost($_strHost)
Defines the Host Name or IP of the Mail Server to use.
getFrom($_part=true)
Retrieves the Address from which mail will be sent.
getHost()
Retrieves the Host Name or IP of the Mail Server to use This is used only with 'socket' based mail tr...
setPW($_strPW)
User Password for authentication on Mail Server.
getReplyTo($_part=true)
Retrieves the Address from which mail will be the reply-to.
setPriority($_value=3)
Message Content Priority Message Priority values:
setMoreInHeader($_val='')
Set moreInHeader.
getErrorsTo($_part=true)
Get errors to.
getSensitivity()
Returns Message Content Sensitivity string Message Sensitivity values:
setSMTPTimeout($timeout)
Set socket timeout.
getPort()
Retrieves the Port Number of the Mail Server to use This is used only with 'socket' based mail transm...
getTransportType()
Return the method inwhich the message is to be sent.
setMailPath($_path)
Path to the sendmail executable.
getTransEncode()
Retrieves the Content-Transfer-Encoding.
getReferences()
Retrieves the References from which mail will be the reply-to.
setTransEncode($_strTransEncode)
Content-Transfer-Encoding, Defaulted to '7bit' This can be changed for 2byte characters sets Known En...
setDebug($_vDebug=false)
Set debug.
setDeliveryReceipt($_val=0)
Set delivery receipt.
_setErr($_errNum, $_errMsg)
Defines errors codes and messages for Class.
getHeader()
Constructs and returns message header.
setXheader($strXdata)
Message X-Header Content This is a simple "insert".
is_ip($ip)
This function evaluates a string that should be a valid IPv4 Note: For ip 169.254....
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
getDomainFromURL($url, $mode=0)
Function get second level domain name.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.