J
J
JoniSuper2018-12-24 19:16:40
PHP
JoniSuper, 2018-12-24 19:16:40

Trouble with PHPMAILER?

When writing the code, I don’t understand where this error comes from:
5c21063478811430055234.png
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

1 answer(s)
A
Alexey, 2018-12-24
@alexxxst

$_FILES['file'] is an array and expects a string. The text of the error is still written. You need to start with English, then in a mess.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question