Answer the question
In order to leave comments, you need to log in
What is the problem with phpmailer?
With this code, nothing happens, just a blank page opens
use PHPMailer\PHPMailer\PHPMailer;
require_once "PHPMailer/PHPMailer.php";
require_once "PHPMailer/Exception.php";
require_once "PHPMailer/SMTP.php";
$name = $_POST['name'];
$mail = $_POST['mail'];
$phone = $_POST['phone'];
$mail = new PHPMailer();
//Server settings
$mail->isSMTP(); // Send using SMTP
$mail->Host = 'smtp.mail.ru'; // Set the SMTP server to send through
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '"[email protected]'; // SMTP username
$mail->Password = 'dfefesfgr'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
$mail->Port = 465; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
//Recipients
$mail->setFrom('[email protected]');
$mail->addAddress('[email protected]'); // Add a recipient
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Заяка с сайта!';
$mail->Body = '
$name отправил реквест <br><br>
Его контактная информация: $phone $mail';
if($mail->send()) {
header('location: thank-you.html');
} else {
$mail->ErrorInfo;
}
Answer the question
In order to leave comments, you need to log in
var_dump($mail->ErrorInfo);
PS
$mail->Body = '
$name отправил реквест <br><br>
Его контактная информация: $phone $mail';
The quotes must be double and the $mail variable is overwritten.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question