function invia_email($destinatario, $soggetto, $corpo_html, $cc = '', $bcc = '', $allegato_path = '', $allegato_nome = '') { global $pdo; // necessario per il log $mail = new PHPMailer(true); $esito = 'inviato'; $errore = null; try { $mail->isSMTP(); $mail->Host = 'mail.studiomenichetti.com'; $mail->SMTPAuth = true; $mail->Username = 'info@studiomenichetti.com'; $mail->Password = 'PwdScm2018!!'; $mail->SMTPSecure = 'tls'; $mail->Port = 587; $mail->setFrom('email@tuodominio.it', APP_NAME); $mail->addAddress($destinatario); if ($cc) $mail->addCC($cc); if ($bcc) $mail->addBCC($bcc); if ($allegato_path) $mail->addAttachment($allegato_path, $allegato_nome ?: basename($allegato_path)); $mail->isHTML(true); $mail->Subject = $soggetto; $mail->Body = $corpo_html; $mail->send(); } catch (Exception $e) { $esito = 'errore'; $errore = $mail->ErrorInfo; log_error("Errore invio email: " . $errore); } // LOG email $stmt = $pdo->prepare("INSERT INTO log_email (mittente, destinatario, cc, bcc, oggetto, messaggio, allegato_nome, stato, errore) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); $stmt->execute([ 'email@tuodominio.it', $destinatario, $cc, $bcc, $soggetto, $corpo_html, $allegato_nome, $esito, $errore ]); return $esito === 'inviato'; } Recupero Password

Recupera la tua password

Annulla