Answer the question
In order to leave comments, you need to log in
Trouble with PHPMAILER?
When writing the code, I don’t understand where this error comes from:
Here is the code
<<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'src/src/Exception.php';
require 'src/src/PHPMailer.php';
require 'src/src/SMTP.php';
if (isset($_POST['sub'])) {
# code...
$mail = new PHPMailer;
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'xxxxxxxxx'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->setFrom('[email protected]');
$mail->addAddress('[email protected]');
$mail->addAttachment($_FILES['file']); // Add attachments
$mail->addAttachment($_FILES['file']);
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
// Optional namefile_get_contents(
$mail->send;
if ($mail->send) {
# code...
echo "1";
}
}
?>
<form enctype='multipart/form-data' action="test.php" method="POST">
<input type="file" name="file[]" multiple>
<input type="file" name="file[]" multiple>
<input type="file" name="file[]" multiple>
<input type="submit" name="sub">
</form>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question