118car. contenant plus de 1 point '.' dans le nom pour voir si l'extension n'est pas détruite ligne 92 * */ function sendamail($from, $to, $sujet, $corps, $txtbrut = "", $pas_de_txt2html = "", $pas_entete_html = "", $fichiers_attaches = array(), $copyToAdmin = true, $bcc = '') { $sujet = stripslashes($sujet); $corps = stripslashes($corps); $to = trim($to); $from = trim($from); // securité if (sendamail_check_value($from) || sendamail_check_value($to) || sendamail_check_value($sujet) || sendamail_check_value($bcc)) { $message = "Tentative d'injection le ".date("d/m/Y H:i:s")." sur le site ".ROOT_URL; $message .= "\n\n"; $message .= "From:\n$from\n\nTo:\n$to\n\nSujet:\n$sujet\n\nMessage:\n$corps\n\nbcc:$bcc"; mail(ADMIN_EMAIL, "[Email Injection] ".ROOT_URL, $message, "From:".ADMIN_EMAIL); return false; } $corps = str_replace("\r\n", "\n", $corps); $corps = str_replace("\r", "\n", $corps); $corps = str_replace("\n", "\r\n", $corps); $mail = new mime_mail(); $mail->to = $to; $mail->from = $from; $mail->subject = $sujet; if ($bcc != '') { $mail->bcc = trim($bcc); } if ($txtbrut == "" && $pas_entete_html == "") { $html_avant = "".htmlentities($sujet).""; $html_apres = ""; } if ($fichiers_attaches != '' && sizeof($fichiers_attaches) > 0) { foreach ($fichiers_attaches as $filepath => $nomdufichier) { //echo "attachement filename origin $nomdufichier
"; $attachment = fread(fopen($filepath, "r"), filesize($filepath)); // Sur certains serveur la taille du nom de fichier attaché est limitée a 118 caractère // Au dela le fichier est renommé en .dat // Pour eviter on raccoucit le nom de fichier si necessaire if (strlen($nomdufichier) > 118) { $p = explode(".", $nomdufichier); if (count($p) > 0) { $filename = $p[0]; $file_extension = $p[1]; $nomdufichier = substr($filename, 0, (118 - strlen($file_extension) - 1)).".".$file_extension; } else { $nomdufichier = substr($filename, 0, (118)); } } //echo "attachement filename shorten $nomdufichier
"; $mail->add_attachment("$attachment", "$nomdufichier", $mail->get_content_type($nomdufichier)); unset($attachment); // saves some memory space :) } // fin de foreach } if ($txtbrut == "") { if ($pas_de_txt2html == "") { $msghtml = $html_avant.txt2html($corps).$html_apres; } else { $msghtml = $html_avant.$corps.$html_apres; } $mail->body = wordwrap($msghtml, 72); $mail->html = "1"; //echo "mailHTML"; } else { // a priori pas neccesaire en texte brut //$mail->body = wordwrap($corps,72); $mail->body = $corps; $mail->mailText = 1; } //On envoie une copie à webmaster si ce n'est pas lui le destinataire if ($copyToAdmin && $mail->to != ADMIN_EMAIL) { $mailCopie = clone $mail; $mailCopie->subject = "[COPY][".$mailCopie->to."]".$mailCopie->subject; $mailCopie->to = ADMIN_EMAIL; $mailCopie->send(); } $retour = $mail->send(); return $retour; } /** * @package Mail * Protection anti injection dans les entetes du mail (anti spam) * @param string $value Valeur à tester * @param boolean $check_all_patterns vérifier toutes les empreintes d'injection ou seulement les basiques (to:, cc:, bcc:, ...) * @return boolean true si on a une tentative d'injection */ function sendamail_check_value($value, $check_all_patterns = true) { $value = preg_replace('/mailto:/i', "mailtwo:", $value); if ($check_all_patterns == true) { if (preg_match("#\r#", $value) || preg_match("#\n#", $value) || preg_match("#%0a#", $value) || preg_match("#%0d#", $value) || preg_match("#Content-Type:#i", $value) || preg_match("#bcc:#i", $value) || preg_match("#to:#i", $value) || preg_match("#cc:#i", $value)) { return true; } else { return false; } } else { if (preg_match("#%0a#", $value) || preg_match("#%0d#", $value) || preg_match("#Content-Type:#i", $value) || preg_match("#bcc:#i", $value) || preg_match("#to:#i", $value) || preg_match("#cc:#i", $value)) { return true; } else { return false; } } } ?> 信息 CAD 转换器、SDK、人力资源等...请联系Datakit

联系
Datakit

发送电子邮件时出错。

您是 ...

联系我们以获取
获取更多信息
  • 应用程序开发人员
    有兴趣将 Datakit 数据转换SDK集成到您的软件中。
  • 工程软件用户
    对 Datakit 文件转换器感兴趣。
  • 渴望加入Datakit团队
  • 其他 ...