Fix: Can provide ip address on smtps. Better error reporting.

This commit is contained in:
Laurent Destailleur 2010-04-13 20:30:25 +00:00
parent b48377312b
commit c86db093be
4 changed files with 15 additions and 4 deletions

View File

@ -25,6 +25,7 @@ For users:
- Fix: Format number was wrong for ar_AR language.
- Fix: Can change password if has only permission change password.
- Fix: Project PDF document show the tasks.
- Fix: bug #29278 : SMTP fails with IP
For developers:
- More comments in code.

View File

@ -627,7 +627,11 @@ class SMTPs
$host=$this->getHost();
$host=preg_replace('@tcp://@i','',$host); // Remove prefix
$host=preg_replace('@ssl://@i','',$host); // Remove prefix
if ( (gethostbyname ( $host )) == $host )
// DOL_CHANGE LDR
include_once(DOL_DOCUMENT_ROOT.'/lib/functions2.lib.php');
if ( (! is_ip($host)) && ((gethostbyname ( $host )) == $host) )
{
$this->_setErr ( 99, $host . ' is either offline or is an invalid host name.' );
$_retVal = false;
@ -1996,7 +2000,7 @@ class SMTPs
*/
//$content = 'Content-Type: multipart/related; boundary="' . $this->_getBoundary() . '"' . "\r\n";
$content = 'Content-Type: multipart/mixed; boundary="' . $this->_getBoundary() . '"' . "\r\n";
// TODO Restore
// . "\r\n"
// . 'This is a multi-part message in MIME format.' . "\r\n";
@ -2513,6 +2517,9 @@ class SMTPs
/**
* $Log$
* Revision 1.12 2010/04/13 20:30:25 eldy
* Fix: Can provide ip address on smtps. Better error reporting.
*
* Revision 1.11 2010/01/12 13:02:07 hregis
* Fix: missing attach-files
*

View File

@ -401,7 +401,10 @@ class CMailFile
{
if (! empty($conf->global->MAIN_MAIL_DEBUG)) $this->smtps->setDebug(true);
$result=$this->smtps->sendMsg();
//print $resultvalue;
if (! $result)
{
$this->error=$this->smtps->getErrors();
}
}
if (! empty($conf->global->MAIN_MAIL_DEBUG)) $this->dump_mail();

View File

@ -1101,7 +1101,7 @@ function getListOfModels($db,$type)
*/
function is_ip($ip)
{
if (!ereg("^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$", $ip)) return 0;
if (!preg_match("/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/", $ip)) return 0;
if (sprintf("%u",ip2long($ip)) == sprintf("%u",ip2long('255.255.255.255'))) return 0;
if (sprintf("%u",ip2long('10.0.0.0')) <= sprintf("%u",ip2long($ip)) and sprintf("%u",ip2long($ip)) <= sprintf("%u",ip2long('10.255.255.255'))) return 2;
if (sprintf("%u",ip2long('172.16.0.0')) <= sprintf("%u",ip2long($ip)) and sprintf("%u",ip2long($ip)) <= sprintf("%u",ip2long('172.31.255.255'))) return 2;