Mailer Error: Could not access file PHP Mailer

0

My problem is as follows. I am trying to attach a file pdf by means of the function AddAttachment of PHPMailer but it throws me the following error:

  

"Message could not be sent. Mailer Error: Could not access file:   /app/OPER/certificado/CERCOL-1770-1771.pdf ".

Code:

<?php 
use PHPMailer\PHPMailer\PHPMailer; 
use PHPMailer\PHPMailer\Exception;
//Load Composer's autoloader
require 'autoload.php';
class mail {
  function correo($correo,$correo1,$nombre,$subject,$body) {
$mail = new PHPMailer(true);                              // Passing 'true' enables exceptions
try {
    //Server settings
    $mail->SMTPDebug = 0;                                 // Enable verbose debug output
    $mail->isSMTP();                                      // Set mailer to use SMTP
    $mail->Host = 'mail.aaaa.org';  // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                               // Enable SMTP authentication
    $mail->Username = '[email protected]';                 // SMTP username
    $mail->Password = 'XxxxxxS';                           // SMTP password
    $mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, 'ssl' also accepted
    $mail->Port = 465;                                    // TCP port to connect to

    //Recipients
    $mail->setFrom('[email protected]', 'data S.A.S');
    $mail->addAddress($correo, $nombre);     // Add a recipient
    if (isset($correo1)&&filter_var($correo1, FILTER_VALIDATE_EMAIL)) {
      $mail->addAddress($correo1);               // Name is optional
    }

    $mail->addReplyTo('[email protected]', 'Información');


    //Attachments
    $emailAttachment='/app/OPER/certificado/participacion/repositorio/CERCOL-1770-1771.pdf';
    $mail->AddAttachment($emailAttachment, 'file.pdf');         // Add attachments


    //Content
    $mail->isHTML(true);
    // Activo condificacción utf-8
    $mail->CharSet = 'UTF-8';                                // Set email format to HTML
    $mail->Subject = $subject;
    $mail->Body    = $body;
    //$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;
}   
}
}
?>
    
asked by yeysondavidp 17.09.2018 в 22:08
source

0 answers