Sto tentando di usare per ora solo in locale (XAMPP) l'ultima versione di phpmailer, ma ricevo un errore:
Could not instantiate mail function.
Codice PHP:
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require_once '../include/PHPMailer/Exception.php';
require_once '../include/PHPMailer/PHPMailer.php';
require_once '../include/PHPMailer/SMTP.php';
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
$mail->Port = 25; // TCP port to connect to
$mail->setFrom('email@email.it', 'Mailer');
$mail->addAddress('email@email.it', 'Joe User'); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $oggetto;
$mail->Body = $testo;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; $mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}