PHP mailer non invia l'email

di il
3 risposte

PHP mailer non invia l'email

<?php
//These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
if(isset($_POST['name']) && isset($_POST['surname']) && isset($_POST['email']) && isset($_POST['mex'])){

$name = $_POST['name'];
$surname = $_POST['surname'];
$_email = $_POST['email'];
$mex = $_POST['mex'];

require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';


//Import PHPMailer classes into the global namespace




//Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);

try {
//Server settings
$mail->SMTPDebug = 4; //Enable verbose debug output
// $mail->isSMTP(); //Send using SMTP
$mail->Host = 'smtp.live.com'; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = '***'; //SMTP username
$mail->Password = '***';
//SMTP password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; //Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
$mail->Port = 587; //TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above

//Recipients
$mail->setFrom("***");
$mail->addAddress("***","Amica" ); //Add a recipient
/* $mail->addAddress('***'); //Name is optional
$mail->addReplyTo('***', 'Information');
$mail->addCC('***');
$mail->addBCC('***');

//Attachments
$mail->addAttachment('/var/tmp/file.tar.gz'); //Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); */ //Optional name

//Content
$mail->isHTML(true); //Set email format to HTML
$mail->Subject = 'Contatto cliente ***';
$mail->Body = "$mex";
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

$mail->send();
echo 'Messaggio inviato';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
}
?>


Se conosecete phpmailer mi mostra aschermo questo messaggio e non mi manda l'email

Sending with mail()
Sendmail path: /usr/sbin/sendmail -t -i
Envelope sender: no-reply@***
To: Amica <***@***.com>
Subject: Contatto cliente ***
Headers: Date: Mon, 22 Nov 2021 09:37:46 +0000From: no-reply@***Message-ID: <1BaXCvMZSC2OgndjnZ6uKTjzwf1gO2w3h823gK9tybk@***>X-Mailer: PHPMailer 6.4.1 (https://github.com/PHPMailer/PHPMaile)MIME-Version: 1.0Content-Type: multipart/alternative; boundary="b1_1BaXCvMZSC2OgndjnZ6uKTjzwf1gO2w3h823gK9tybk"Content-Transfer-Encoding: 8bit
Additional params: -fno-reply@***
Result: true
Messaggio inviato


sapreste risolverlo?

3 Risposte

Devi accedere o registrarti per scrivere nel forum
3 risposte