[*] BO : sending a mail is a little less strict with wrong parameters - it tries to send the e-mail, not to die!

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@16539 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
dMetzger
2012-07-24 08:23:25 +00:00
parent eb398f1a9f
commit 8fce66e370
+20 -24
View File
@@ -68,22 +68,24 @@ class MailCore
'PS_MAIL_TYPE' 'PS_MAIL_TYPE'
)); ));
if (!isset($configuration['PS_MAIL_SMTP_ENCRYPTION'])) $configuration['PS_MAIL_SMTP_ENCRYPTION'] = 'off'; if (!isset($configuration['PS_MAIL_SMTP_ENCRYPTION']))
if (!isset($configuration['PS_MAIL_SMTP_PORT'])) $configuration['PS_MAIL_SMTP_PORT'] = 'default'; $configuration['PS_MAIL_SMTP_ENCRYPTION'] = 'off';
if (!isset($configuration['PS_MAIL_SMTP_PORT']))
$configuration['PS_MAIL_SMTP_PORT'] = 'default';
if (!isset($from)) $from = $configuration['PS_SHOP_EMAIL']; // Sending an e-mail can be of vital importance for the merchant, when his password is lost for example, so we must not die but do our best to send the e-mail
if (!isset($fromName)) $fromName = $configuration['PS_SHOP_NAME']; if (!isset($from) || !Validate::isEmail($from))
$from = $configuration['PS_SHOP_EMAIL'];
if (!empty($from) && !Validate::isEmail($from)) if (!Validate::isEmail($from))
{ $from = null;
Tools::dieOrLog(Tools::displayError('Error: parameter "from" is corrupted'), $die);
return false; // $fromName is not that important, no need to die if it is not valid
} if (!isset($fromName) || !Validate::isMailName($fromName))
if (!empty($fromName) && !Validate::isMailName($fromName)) $fromName = $configuration['PS_SHOP_NAME'];
{ if (!Validate::isMailName($fromName))
Tools::dieOrLog(Tools::displayError('Error: parameter "fromName" is corrupted'), $die); $fromName = null;
return false;
} // It would be difficult to send an e-mail if the e-mail is not valid, so this time we can die if there is a problem
if (!is_array($to) && !Validate::isEmail($to)) if (!is_array($to) && !Validate::isEmail($to))
{ {
Tools::dieOrLog(Tools::displayError('Error: parameter "to" is corrupted'), $die); Tools::dieOrLog(Tools::displayError('Error: parameter "to" is corrupted'), $die);
@@ -91,17 +93,11 @@ class MailCore
} }
if (!is_array($templateVars)) if (!is_array($templateVars))
{ $templateVars = array();
Tools::dieOrLog(Tools::displayError('Error: parameter "templateVars" is not an array'), $die);
return false;
}
// Do not crash for this error, that may be a complicated customer name // Do not crash for this error, that may be a complicated customer name
if (is_string($toName)) if (is_string($toName) && !empty($toName) && !Validate::isMailName($toName))
{ $toName = null;
if (!empty($toName) && !Validate::isMailName($toName))
$toName = null;
}
if (!Validate::isTplName($template)) if (!Validate::isTplName($template))
{ {