function send_to_friend() { $db = new Db(); $idPr = $db->str($_POST["idPr"]); $nome = $db->str($_POST["nome"]); $mail = $db->str($_POST["mail"]); $nome_amico = $db->str($_POST["nome_amico"]); $mail_amico = $db->str($_POST["mail_amico"]); $messaggio = $db->str($_POST["messaggio"]); $lang = $_POST["lang"]; if ($lang == "eng") { $suffissoL = ""; require "../config/lingue/inglese.php"; } elseif ($lang == "ted") { $suffissoL = "_ted"; require "../config/lingue/tedesco.php"; } else { $suffissoL = "_ita"; require "../config/lingue/italiano.php"; } //recupero la foto $img = ""; $immagini = new File("pr_prodotti", "img", "anteprima"); $idTbl = $immagini->get_id_tabella(); $arrFoto = $immagini->get_file($idPr); $numTot = count($arrFoto); if ($numTot != 0) { $cartellaUp = $immagini->get_cartella(); $arrayFoto = explode(":", $arrFoto[0]["file"]); $nomeFileImg = dimminomefile($arrayFoto[1]); $tipoFile = tipo_file($arrayFoto[1]); $nomeThumb = $nomeFileImg . "_thumb." . $tipoFile; $img_thumb = UPLOAD_FILE . "/" . $cartellaUp . "/" . $nomeThumb; if (is_file($img_thumb)) { $img .= "<img src='" . LINK_ROOT . $img_thumb . "' width='180'>"; } } //dett prodotto $objProdotto = new Prodotti(); $arrPr = $objProdotto->getById($idPr); $dettPr = ""; if ($arrPr["pr_titolo"] != "") { $dettPr .= "<strong>" . $arrPr["pr_titolo" . $suffissoL] . "</strong><br />"; } $dettPr .= $arrPr["pr_desc" . $suffissoL]; //mando mail $bodyMsg = file_get_contents('../tpl_mail/' . $lang . '/send_friend.html'); $bodyMsg = str_replace("XX_URL_XX", LINK_ROOT, $bodyMsg); $bodyMsg = str_replace("XX_NOMEAMICO_XX", $nome_amico, $bodyMsg); $bodyMsg = str_replace("XX_NOME_XX", $nome, $bodyMsg); $bodyMsg = str_replace("XX_MAIL_XX", $mail, $bodyMsg); $bodyMsg = str_replace("XX_MESSAGGIO_XX", $messaggio, $bodyMsg); $bodyMsg = str_replace("XX_IMG_XX", $img, $bodyMsg); $bodyMsg = str_replace("XX_PRODOTTO_XX", $dettPr, $bodyMsg); $bodyMsg = str_replace("XX_LINK_XX", LINK_ROOT . "product_dett.php?idPr=" . $idPr, $bodyMsg); $mailer2 = new PHPMailer(); $mailer2->IsSMTP(); $mailer2->Port = 25; $mailer2->Host = "localhost"; $mailer2->CharSet = "UTF-8"; $mailer2->IsMail(); $mailer2->AddReplyTo($mail); $mailer2->From = $mail; $mailer2->FromName = $nome; $mailer2->AddAddress(trim($mail_amico)); //$mailer2->Subject = $nome." ".utf8_decode($lang_consigliaprodotto); $mailer2->Subject = "=?UTF-8?B?" . base64_encode($nome . " " . $lang_consigliaprodotto) . "?="; $mailer2->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mailer2->WordWrap = 80; $mailer2->MsgHTML($bodyMsg); $mailer2->IsHTML(true); if (!$mailer2->Send()) { $error = $mailer2->ErrorInfo . "\n"; print 0; } else { print 1; } unset($mailer2); }