skip to Main Content

I have a problem with setting up PHPMailer. It was working before, but now all of a sudden it stopped and this is the error I’m getting:
PHP Fatal error: require(): Failed opening required '../src/PHPMailer.php' (include_path='.:/opt/cpanel/ea-php53/root/usr/share/pear:/opt/cpanel/ea-php53/root/usr/share/php') in /home/pandatra/site.com/contacts_form/contact_form.php on line 9

Here is the code in contact_form.php:

<?php

    include 'config.php';

    use PHPMailerPHPMailerPHPMailer;
    use PHPMailerPHPMailerException;
    use PHPMailerPHPMailerSMTP;

    require ''.$d['include_path'].'PHPMailer/src/Exception.php';
    require ''.$d['include_path'].'PHPMailer/src/PHPMailer.php';
    require ''.$d['include_path'].'PHPMailer/src/SMTP.php';
    
    $mail = new PHPMailer(true);

  if (isset($_POST['Send'])) {

How to fix this? Any ideas? I downloaded version 6.1.7 of PHPMailer.

2

Answers


  1. Here’s the problem:

    I just replaced the old version with the new one

    If you upgraded from 5.x to 6.x, you needed to read either the readme, the upgrade guide, or this question and answer that was specifically created to deal with this issue.

    Login or Signup to reply.
  2. The error you mentioned is that, the path in your require is getting Wrong. To avoid this type of problem , you should always use absolute path

    e.g.

        require __DIR__.'/PHPMailer/src/Exception.php';
        require __DIR__.'/PHPMailer/src/PHPMailer.php';
        require __DIR__.'/PHPMailer/src/SMTP.php';
    
       # use "use" after include or require
    
        use PHPMailerPHPMailerPHPMailer;
        use PHPMailerPHPMailerException;
        use PHPMailerPHPMailerSMTP;
    
    

    __DIR__ is the absolute path of running file’s directory.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search