53 private $_smtpsHost =
'localhost';
61 private $_smtpsPort = 25;
67 private $_smtpsID =
null;
73 private $_smtpsPW =
null;
78 private $_smtpsToken =
null;
84 private $_msgFrom =
null;
90 private $_msgReplyTo =
null;
95 private $_msgInReplyTo =
null;
100 private $_msgReferences =
null;
107 private $_msgRecipients =
null;
112 private $_msgSubject =
null;
119 private $_msgContent = array();
124 private $_msgXheader = array();
131 private $_smtpsCharSet =
'iso-8859-1';
138 private $_msgSensitivity = 0;
143 private $_arySensitivity = array(
false,
146 'Company Confidential');
152 private $_msgPriority = 3;
157 private $_aryPriority = array(
'Bulk',
168 private $_smtpsTransEncodeType = 0;
173 private $_smtpsTransEncodeTypes = array(
'7bit',
186 private $_smtpsTransEncode =
'7bit';
191 private $_smtpsBoundary =
null;
196 private $_smtpsRelatedBoundary =
null;
201 private $_smtpsAlternativeBoundary =
null;
211 private $_transportType = 0;
217 private $_mailPath =
'/usr/lib/sendmail';
222 private $_smtpTimeout = 10;
227 private $_smtpMD5 =
false;
232 private $_smtpsErrors = array();
241 private $_log_level = 0;
246 private $_debug =
false;
257 public $lastretval =
'';
277 private $_errorsTo = array();
281 private $_deliveryReceipt = 0;
285 private $_trackId =
'';
289 private $_moreinheader =
'';
294 private $_options = array();
304 $this->_options = $_options;
315 $this->_deliveryReceipt = $_val;
325 return $this->_deliveryReceipt;
336 $this->_trackId = $_val;
347 $this->_moreinheader = $_val;
357 return $this->_trackId;
367 return $this->_moreinheader;
393 if ($_part ===
true || !array_key_exists($_part, $this->_errorsTo)) {
394 $_retValue = $this->_errorsTo;
396 $_retValue = $this->_errorsTo[$_part];
410 $this->_debug = $_vDebug;
421 $_aryToList = $this->
getTo();
440 $usetls = preg_match(
'@tls://@i', $host);
442 $host = preg_replace(
'@tcp://@i',
'', $host);
443 $host = preg_replace(
'@ssl://@i',
'', $host);
444 $host = preg_replace(
'@tls://@i',
'', $host);
447 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
449 if ((!
is_ip($host)) && ((gethostbyname($host)) == $host)) {
450 $this->
_setErr(99, $host.
' is either offline or is an invalid host name.');
453 if (function_exists(
'stream_socket_client') && !empty($this->_options)) {
454 $socket_context = stream_context_create($this->_options);
455 $this->socket = @stream_socket_client(
456 preg_replace(
'@tls://@i',
'', $this->
getHost()).
461 STREAM_CLIENT_CONNECT,
465 $this->socket = @fsockopen(
466 preg_replace(
'@tls://@i',
'', $this->
getHost()),
475 if (is_resource($this->socket)) {
480 if (function_exists(
'stream_set_timeout')) {
481 stream_set_timeout($this->socket, $this->_smtpTimeout, 0);
485 if ($_retVal = $this->
server_parse($this->socket,
"220")) {
486 $_retVal = $this->socket;
491 if (empty($this->errstr)) {
492 $this->errstr =
'Failed to connect with fsockopen host='.$this->getHost().
' port='.$this->
getPort();
494 $this->
_setErr($this->errno, $this->errstr);
513 require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
518 $usetls = preg_match(
'@tls://@i', $host);
520 $host = preg_replace(
'@tcp://@i',
'', $host);
521 $host = preg_replace(
'@ssl://@i',
'', $host);
522 $host = preg_replace(
'@tls://@i',
'', $host);
525 $host =
'tls://'.$host;
537 $hosth = (string) $this->
getFrom(
'addr');
538 $hosth = preg_replace(
'/^.*</',
'', $hosth);
539 $hosth = preg_replace(
'/>.*$/',
'', $hosth);
540 $hosth = preg_replace(
'/.*@/',
'', $hosth);
543 global $dolibarr_main_url_root;
603 $this->
_setErr(131,
'STARTTLS connection is not supported.');
614 $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT;
615 if (defined(
'STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) {
616 $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
617 $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
620 if (!stream_socket_enable_crypto($this->socket,
true, $crypto_method)) {
621 $this->
_setErr(132,
'STARTTLS connection failed.');
627 $this->
_setErr(126,
'"'.$hosth.
'" does not support authenticated connections or temporary error. Error after 2nd sending EHLO '.$hosth.
' : '.$this->lastretval);
634 $conf->global->MAIN_MAIL_SMTPS_AUTH_TYPE =
'LOGIN';
639 switch ($conf->global->MAIN_MAIL_SMTPS_AUTH_TYPE) {
647 $_retVal = $this->
socket_send_str(base64_encode(
"\0".$this->_smtpsID.
"\0".$this->_smtpsPW),
'235');
651 $user = $this->_smtpsID;
652 $token = $this->_smtpsToken;
653 $initRes =
"user=".$user.
"\001auth=Bearer ".$token.
"\001\001";
654 $_retVal = $this->
socket_send_str(
'AUTH XOAUTH2 '.base64_encode($initRes),
'235');
656 $this->
_setErr(130,
'Error when asking for AUTH XOAUTH2');
663 $this->
_setErr(130,
'Error when asking for AUTH LOGIN');
666 $this->
socket_send_str(base64_encode((
string) $this->_smtpsID),
'334');
669 $_retVal = $this->
socket_send_str(base64_encode((
string) $this->_smtpsPW),
'235');
674 $this->
_setErr(130,
'Invalid Authentication Credentials.');
677 $this->
_setErr(126,
'"'.$host.
'" refused the EHLO command. Error after sending EHLO '.$hosth.
' : '.$this->lastretval);
690 require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
698 if (!empty($this->_smtpsID) && (!empty($this->_smtpsPW) || !empty($this->_smtpsToken))) {
705 $usetls = preg_match(
'@tls://@i', $host);
707 $host = preg_replace(
'@tcp://@i',
'', $host);
708 $host = preg_replace(
'@ssl://@i',
'', $host);
709 $host = preg_replace(
'@tls://@i',
'', $host);
712 $host =
'tls://'.$host;
724 $hosth = (string) $this->
getFrom(
'addr');
725 $hosth = preg_replace(
'/^.*</',
'', $hosth);
726 $hosth = preg_replace(
'/>.*$/',
'', $hosth);
727 $hosth = preg_replace(
'/.*@/',
'', $hosth);
730 global $dolibarr_main_url_root;
745 if (!$resultmailfrom) {
746 fclose($this->socket);
781 fwrite($this->socket,
'QUIT');
786 fclose($this->socket);
831 if (!empty($_strConfigPath)) {
834 if (!@include $_strConfigPath) {
835 $this->
_setErr(110,
'"'.$_strConfigPath.
'" is not a valid path.');
842 if ($_host = ini_get(
'SMTPs')) {
846 if ($_port = ini_get(
'smtp_port')) {
850 if ($_from = ini_get(
'sendmail_from')) {
870 if ((is_numeric($_type)) && (($_type >= 0) && ($_type <= 3))) {
871 $this->_transportType = $_type;
885 return $this->_transportType;
914 $this->_smtpsHost = $_strHost;
926 return $this->_smtpsHost;
939 if ((is_numeric($_intPort)) &&
940 (($_intPort >= 1) && ($_intPort <= 65536))) {
941 $this->_smtpsPort = (int) $_intPort;
953 return (
int) $this->_smtpsPort;
964 $this->_smtpsID = $_strID;
974 return $this->_smtpsID;
985 $this->_smtpsPW = $_strPW;
995 return $this->_smtpsPW;
1006 $this->_smtpsToken = $_strToken;
1016 return $this->_smtpsToken;
1029 $this->_smtpsCharSet = $_strCharSet;
1040 return $this->_smtpsCharSet;
1060 if (array_search($_strTransEncode, $this->_smtpsTransEncodeTypes)) {
1061 $this->_smtpsTransEncode = $_strTransEncode;
1072 return $this->_smtpsTransEncode;
1093 if (array_search($_strTransEncodeType, $this->_smtpsTransEncodeTypes)) {
1094 $this->_smtpsTransEncodeType = $_strTransEncodeType;
1105 return $this->_smtpsTransEncodeTypes[$this->_smtpsTransEncodeType];
1134 if ($_part ===
true || $this->_msgFrom ===
null) {
1135 $_retValue = $this->_msgFrom;
1137 $_retValue = $this->_msgFrom[$_part];
1152 $this->_msgReplyTo = $this->
_strip_email($_strReplyTo);
1166 if ($_part ===
true) {
1167 $_retValue = $this->_msgReplyTo;
1169 $_retValue = $this->_msgReplyTo[$_part];
1183 if ($_strInReplyTo) {
1184 $this->_msgInReplyTo = $_strInReplyTo;
1195 $_retValue = $this->_msgInReplyTo;
1208 if ($_strReferences) {
1209 $this->_msgReferences = $_strReferences;
1220 $_retValue = $this->_msgReferences;
1238 $aryHost = $this->_msgRecipients;
1241 if (!empty($_addrList)) {
1243 if (is_string($_addrList)) {
1245 if (strstr($_addrList,
',')) {
1247 $_addrList = explode(
',', $_addrList);
1250 $_addrList = array($_addrList);
1255 foreach ($_addrList as $_strAddr) {
1257 $_strAddr = str_replace(
'>',
'', $_strAddr);
1261 $_tmpaddr = explode(
'<', $_strAddr);
1264 if (count($_tmpaddr) == 2) {
1265 $_tmpHost = explode(
'@', $_tmpaddr[1]);
1266 $_tmpaddr[0] = trim($_tmpaddr[0],
' ">');
1267 $aryHost[$_tmpHost[1]][$_type][$_tmpHost[0]] = $_tmpaddr[0];
1271 $_strAddr = str_replace(
'<',
'', $_strAddr);
1273 $_tmpHost = explode(
'@', $_strAddr);
1274 $_tmpHost[0] = trim($_tmpHost[0]);
1275 $_tmpHost[1] = trim($_tmpHost[1]);
1277 $aryHost[$_tmpHost[1]][$_type][$_tmpHost[0]] =
'';
1282 $this->_msgRecipients = $aryHost;
1305 $_aryEmail = array();
1307 $_aryEmail[
'org'] = $_strAddr;
1310 $_strAddr = strtolower($_strAddr);
1313 $_strAddr = trim($_strAddr,
' ">');
1316 $_tmpAry = explode(
'<', $_strAddr);
1319 if (count($_tmpAry) == 2) {
1322 $_aryEmail[
'real'] = trim($_tmpAry[0],
' ">');
1325 $_aryEmail[
'addr'] = $_tmpAry[1];
1327 $_aryEmail[
'addr'] = $_tmpAry[0];
1331 $_tmpHost = explode(
'@', $_aryEmail[
'addr']);
1332 $_aryEmail[
'user'] = $_tmpHost[0];
1333 $_aryEmail[
'host'] = $_tmpHost[1];
1336 $_aryEmail[
'addr'] =
'<'.$_aryEmail[
'addr'].
'>';
1355 $_RCPT_list = array();
1358 foreach ($this->_msgRecipients as $_host => $_list) {
1359 foreach ($_list as $_subList) {
1360 foreach ($_subList as $_name => $_addr) {
1362 $_RCPT_list[] = $_name.
'@'.$_host;
1383 if ($this->_msgRecipients) {
1384 $_RCPT_list = array();
1386 foreach ($this->_msgRecipients as $_host => $_list) {
1387 if (!empty($this->_msgRecipients[$_host][$_which])) {
1388 foreach ($this->_msgRecipients[$_host][$_which] as $_addr => $_realName) {
1390 $_realName =
'"'.$_realName.
'"';
1391 $_RCPT_list[] = $_realName.
' <'.$_addr.
'@'.$_host.
'>';
1393 $_RCPT_list[] = $_addr.
'@'.$_host;
1399 return implode(
', ', $_RCPT_list);
1401 $this->
_setErr(101,
'No eMail Address for message to be sent to.');
1405 $this->
_setErr(102,
'eMail type not defined.');
1488 $this->_msgSubject = $_strSubject;
1499 return $this->_msgSubject;
1511 $_header =
'From: '.$this->getFrom(
'org').
"\r\n"
1512 .
'To: '.$this->getTo().
"\r\n";
1514 if ($this->
getCC()) {
1515 $_header .=
'Cc: '.$this->getCC().
"\r\n";
1529 $host = dol_getprefix(
'email');
1532 $_header .=
'Subject: '.$this->getSubject().
"\r\n";
1533 $_header .=
'Date: '.date(
"r").
"\r\n";
1537 $_header .=
'Message-ID: <'.time().
'.SMTPs-dolibarr-'.$trackid.
'@'.$host.
">\r\n";
1538 $_header .=
'X-Dolibarr-TRACKID: '.$trackid.
'@'.$host.
"\r\n";
1540 $_header .=
'Message-ID: <'.time().
'.SMTPs@'.$host.
">\r\n";
1542 if (!empty($_SERVER[
'REMOTE_ADDR'])) {
1543 $_header .=
"X-RemoteAddr: ".$_SERVER[
'REMOTE_ADDR'].
"\r\n";
1550 $_header .=
'Sensitivity: '.$this->getSensitivity().
"\r\n";
1553 if ($this->_msgPriority != 3) {
1560 $_header .=
'Disposition-Notification-To: '.$this->getFrom(
'addr').
"\r\n";
1563 $_header .=
'Errors-To: '.$this->getErrorsTo(
'addr').
"\r\n";
1566 $_header .=
"Reply-To: ".$this->getReplyTo(
'addr').
"\r\n";
1569 $_header .=
'X-Mailer: Dolibarr version '.DOL_VERSION.
' (using SMTPs Mailer)'.
"\r\n";
1570 $_header .=
'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART ?
'MAIN_MAIL_USE_MULTI_PART' :
'No MAIN_MAIL_USE_MULTI_PART').
"\r\n";
1571 $_header .=
'Mime-Version: 1.0'.
"\r\n";
1575 $_header .=
"In-Reply-To: ".$this->getInReplyTo().
"\r\n";
1578 $_header .=
"References: ".$this->getReferences().
"\r\n";
1595 if ($strType ==
'html') {
1596 $strMimeType =
'text/html';
1598 $strMimeType =
'text/plain';
1602 $strContent = preg_replace(
"/(?<!\r)\n/si",
"\r\n", $strContent);
1604 $strContentAltText =
'';
1605 if ($strType ==
'html') {
1607 $strContentAltText = preg_replace(
'/<head><title>.*<\/style><\/head>/',
'', $strContent);
1608 $strContentAltText = preg_replace(
"/<br\s*[^>]*>/",
" ", $strContentAltText);
1609 $strContentAltText = html_entity_decode(strip_tags($strContentAltText));
1610 $strContentAltText = trim(wordwrap($strContentAltText, 75,
"\r\n"));
1615 $strContent = rtrim(wordwrap($strContent, 75,
"\r\n"));
1617 $this->_msgContent[$strType] = array();
1619 $this->_msgContent[$strType][
'mimeType'] = $strMimeType;
1620 $this->_msgContent[$strType][
'data'] = $strContent;
1621 $this->_msgContent[$strType][
'dataText'] = $strContentAltText;
1624 $this->_msgContent[$strType][
'md5'] =
dol_hash($strContent,
'3');
1642 $_types = array_keys($this->_msgContent);
1645 $keyCount = count($_types);
1648 if ($keyCount === 0) {
1649 die(
"Sorry, no content");
1652 $_msgData = $this->_msgContent;
1653 $_msgData = $_msgData[$_types[0]];
1655 $content =
'Content-Type: '.$_msgData[
'mimeType'].
'; charset="'.$this->
getCharSet().
'"'.
"\r\n"
1656 .
'Content-Transfer-Encoding: '.$this->getTransEncodeType().
"\r\n"
1657 .
'Content-Disposition: inline'.
"\r\n"
1658 .
'Content-Description: Message'.
"\r\n";
1661 $content .=
'Content-MD5: '.$_msgData[
'md5'].
"\r\n";
1665 . $_msgData[
'data'].
"\r\n";
1673 $content =
'Content-Type: multipart/mixed; boundary="'.$this->_getBoundary(
'mixed').
'"'.
"\r\n";
1677 $content .=
"Content-Transfer-Encoding: 8bit\r\n";
1680 $content .=
"--".$this->_getBoundary(
'mixed').
"\r\n";
1682 if (array_key_exists(
'image', $this->_msgContent)) {
1683 $content .=
'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary(
'alternative').
'"'.
"\r\n";
1685 $content .=
"--".$this->_getBoundary(
'alternative').
"\r\n";
1693 foreach ($this->_msgContent as $type => $_content) {
1694 if ($type ==
'attachment') {
1696 foreach ($_content as $_file => $_data) {
1697 $content .=
"--".$this->_getBoundary(
'mixed').
"\r\n"
1698 .
'Content-Disposition: attachment; filename="'.$_data[
'fileName'].
'"'.
"\r\n"
1699 .
'Content-Type: '.$_data[
'mimeType'].
'; name="'.$_data[
'fileName'].
'"'.
"\r\n"
1700 .
'Content-Transfer-Encoding: base64'.
"\r\n"
1701 .
'Content-Description: '.$_data[
'fileName'].
"\r\n";
1702 if (!empty($_data[
'cid'])) {
1703 $content .=
"X-Attachment-Id: ".$_data[
'cid'].
"\r\n";
1704 $content .=
"Content-ID: <".$_data[
'cid'].
">\r\n";
1707 $content .=
'Content-MD5: '.$_data[
'md5'].
"\r\n";
1710 $content .=
"\r\n".$_data[
'data'].
"\r\n\r\n";
1712 } elseif ($type ==
'image') {
1715 foreach ($_content as $_image => $_data) {
1716 $content .=
"--".$this->_getBoundary(
'related').
"\r\n";
1718 $content .=
'Content-Type: '.$_data[
'mimeType'].
'; name="'.$_data[
'imageName'].
'"'.
"\r\n"
1719 .
'Content-Transfer-Encoding: base64'.
"\r\n"
1720 .
'Content-Disposition: inline; filename="'.$_data[
'imageName'].
'"'.
"\r\n"
1721 .
'Content-ID: <'.$_data[
'cid'].
'> '.
"\r\n";
1724 $content .=
'Content-MD5: '.$_data[
'md5'].
"\r\n";
1728 . $_data[
'data'].
"\r\n";
1732 $content .=
"--".$this->_getBoundary(
'related').
"--\r\n";
1733 $content .=
"\r\n--".$this->_getBoundary(
'alternative').
"--\r\n";
1736 if (array_key_exists(
'image', $this->_msgContent)) {
1737 $content .=
"Content-Type: text/plain; charset=".$this->getCharSet().
"\r\n";
1738 $content .=
"\r\n".($_content[
'dataText'] ? $_content[
'dataText'] : strip_tags($_content[
'data'])).
"\r\n";
1739 $content .=
"--".$this->_getBoundary(
'alternative').
"\r\n";
1740 $content .=
'Content-Type: multipart/related; boundary="'.$this->_getBoundary(
'related').
'"'.
"\r\n";
1742 $content .=
"--".$this->_getBoundary(
'related').
"\r\n";
1745 if (!array_key_exists(
'image', $this->_msgContent) && $_content[
'dataText'] &&
getDolGlobalString(
'MAIN_MAIL_USE_MULTI_PART')) {
1747 $content .=
'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary(
'alternative').
'"'.
"\r\n";
1749 $content .=
"--".$this->_getBoundary(
'alternative').
"\r\n";
1751 $content .=
"Content-Type: text/plain; charset=".$this->getCharSet().
"\r\n";
1752 $content .=
"\r\n".$_content[
'dataText'].
"\r\n";
1753 $content .=
"--".$this->_getBoundary(
'alternative').
"\r\n";
1756 $content .=
'Content-Type: '.$_content[
'mimeType'].
'; charset='.$this->
getCharSet();
1761 $content .=
'Content-MD5: '.$_content[
'md5'].
"\r\n";
1764 $content .=
"\r\n".$_content[
'data'].
"\r\n";
1766 if (!array_key_exists(
'image', $this->_msgContent) && $_content[
'dataText'] &&
getDolGlobalString(
'MAIN_MAIL_USE_MULTI_PART')) {
1768 $content .=
"--".$this->_getBoundary(
'alternative').
"--\r\n";
1775 $content .=
"--".$this->_getBoundary(
'mixed').
'--'.
"\r\n";
1777 die(
"Sorry, no content");
1793 public function setAttachment($strContent, $strFileName =
'unknown', $strMimeType =
'unknown', $strCid =
'')
1796 $strContent = rtrim(chunk_split(base64_encode($strContent), 76,
"\r\n"));
1798 $this->_msgContent[
'attachment'][$strFileName][
'mimeType'] = $strMimeType;
1799 $this->_msgContent[
'attachment'][$strFileName][
'fileName'] = $strFileName;
1800 $this->_msgContent[
'attachment'][$strFileName][
'data'] = $strContent;
1801 $this->_msgContent[
'attachment'][$strFileName][
'cid'] = $strCid;
1804 $this->_msgContent[
'attachment'][$strFileName][
'md5'] =
dol_hash($strContent,
'3');
1822 public function setImageInline($strContent, $strImageName =
'unknown', $strMimeType =
'unknown', $strImageCid =
'unknown')
1825 $this->_msgContent[
'image'][$strImageName][
'mimeType'] = $strMimeType;
1826 $this->_msgContent[
'image'][$strImageName][
'imageName'] = $strImageName;
1827 $this->_msgContent[
'image'][$strImageName][
'cid'] = $strImageCid;
1828 $this->_msgContent[
'image'][$strImageName][
'data'] = $strContent;
1831 $this->_msgContent[
'image'][$strImageName][
'md5'] =
dol_hash($strContent,
'3');
1851 if ((is_numeric($_value)) &&
1852 (($_value >= 0) && ($_value <= 3))) {
1853 $this->_msgSensitivity = $_value;
1869 return $this->_arySensitivity[$this->_msgSensitivity];
1887 if ((is_numeric($_value)) &&
1888 (($_value >= 0) && ($_value <= 5))) {
1889 $this->_msgPriority = $_value;
1907 return 'Importance: '.$this->_aryPriority[$this->_msgPriority].
"\r\n"
1908 .
'Priority: '.$this->_aryPriority[$this->_msgPriority].
"\r\n"
1909 .
'X-Priority: '.$this->_msgPriority.
' ('.$this->_aryPriority[$this->_msgPriority].
')'.
"\r\n";
1920 $this->_smtpMD5 = $_flag;
1930 return $this->_smtpMD5;
1944 $this->_msgXheader[] = $strXdata;
1955 return $this->_msgXheader;
1965 $this->_smtpsBoundary =
"multipart_x.".time().
".x_boundary";
1966 $this->_smtpsRelatedBoundary =
'mul_'.dol_hash(uniqid(
"dolibarr2"),
'3');
1967 $this->_smtpsAlternativeBoundary =
'mul_'.dol_hash(uniqid(
"dolibarr3"),
'3');
1978 if ($type ==
'mixed') {
1979 return $this->_smtpsBoundary;
1980 } elseif ($type ==
'related') {
1981 return $this->_smtpsRelatedBoundary;
1982 } elseif ($type ==
'alternative') {
1983 return $this->_smtpsAlternativeBoundary;
2008 $server_response =
'';
2013 while (substr($server_response, 3, 1) !=
' ' && $limit < 100) {
2014 if (!($server_response = fgets($socket, 256))) {
2015 $this->
_setErr(121,
"Couldn't get mail server response codes");
2019 $this->log .= $server_response;
2023 $this->lastretval = substr($server_response, 0, 3);
2025 if (!(substr($server_response, 0, 3) == $response)) {
2026 $this->
_setErr(120,
"Ran into problems sending Mail.\r\nResponse: ".$server_response);
2045 if ($this->_debug) {
2046 $this->log .= $_strSend;
2048 fwrite($this->socket, $_strSend.$CRLF);
2049 if ($this->_debug) {
2050 $this->log .=
' ('.$_returnCode.
')'.$CRLF;
2054 return $this->
server_parse($this->socket, $_returnCode);
2072 $this->_smtpsErrors[] = array(
2087 if (is_array($this->_smtpsErrors)) {
2088 foreach ($this->_smtpsErrors as $_err => $_info) {
2089 $_errMsg[] =
'Error ['.$_info[
'num'].
']: '.$_info[
'msg'];
2093 return implode(
"\n", $_errMsg);
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 delivery receipt.
_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.
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...
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:
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.
dol_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.