Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

How to fix " Fatal error: require(): Failed opening required "

20142014 Member
edited July 2015 in Help

How i fix this issue?

Warning: require(/phpmailer/PHPMailerAutoload.php): failed to open stream: No such file or directory in /home/mysitedic/public_html/mailer.php on line 2

Fatal error: require(): Failed opening required '/phpmailer/PHPMailerAutoload.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/mysitedic/public_html/mailer.php on line 2

and

Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

My SMTP settings are right but i don't know why this error coming :(

«1

Comments

  • The error means the file it is looking for does not exist, it is currently looking in the root / and not its current location.

    There is normally a config file or entry that you set to tell it the location of the script such as "/home/mysitedic/public_html/"

    Thanked by 12014
  • It means that the file (PHPMailerAutoload.php) doesn't exist. Maybe the file is located in phpmailer/PHPMailerAutoload.php instead of /phpmailer/PHPMailerAutoload.php? If that's the case, the correct code would be:

    require('phpmailer/PHPMailerAutoload.php');
    

    Basically, just include the correct path for the file and I believe it would work afterwards.

    Thanked by 12014
  • 20142014 Member

    @Verelox Thank you very much.. Now coming

    Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

  • Did the fatal error go away? If so, I would check the SMTP settings - perhaps enabling debug mode might help as well. To do so, insert the following code before attempting to send the message (replace $smtp with the correct variable):

    $smtp->SMTPDebug = 1; 
    
    Thanked by 12014
  • Have you opened your port. If not, that would be the case.

    Thanked by 22014 doghouch
  • 20142014 Member
    edited July 2015

    @Verelox and @sdglhm Here is code im using

     <?php
        require('phpmailer/PHPMailerAutoload.php');
    
        $mail = new PHPMailer;
        //$mail->SMTPDebug = 1;                               // Enable verbose debug output
    
        $mail->IsSMTP();                                      // Set mailer to use SMTP
        $mail->Host = 'smtp.mandrillapp.com';                 // Specify main and backup server
        $mail->Port = 587;                                    // Set the SMTP port
        $mail->SMTPAuth = true;                               // Enable SMTP authentication
        $mail->Username = '[email protected]';                // SMTP username
        $mail->Password = 'WJFu-3T1GFYS-17zTGGsA';                  // SMTP password
        $mail->SMTPSecure = 'tls';                            // Enable encryption, 'ssl' also accepted
    
        $mail->From = '[email protected]';
        $mail->FromName = 'Your From name';
        $mail->AddAddress('[email protected]', 'Josh Adams');  // Add a recipient
        $mail->AddAddress('[email protected]');               // Name is optional
    
        $mail->IsHTML(true);                                  // Set email format to HTML
    
        $mail->Subject = 'Here is the subject';
        $mail->Body    = 'This is the HTML message body <strong>in bold!</strong>';
        $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
    
        if(!$mail->Send()) {
           echo 'Message could not be sent.';
           echo 'Mailer Error: ' . $mail->ErrorInfo;
           exit;
        }
    
        echo 'Message has been sent';
        ?>
    
  • 20142014 Member

    Still not working,., same error :(

  • as far as I know mandrill requires dkim and spf setup, php mailer should not work, I think ;P

  • 20142014 Member

    @century1stop said:
    as far as I know mandrill requires dkim and spf setup, php mailer should not work, I think ;P

    This same settings working in shared Host :) but not working in my New VPS host

  • 2014 said: require('phpmailer/PHPMailerAutoload.php');

    That's saying that the file PHPMailerAutoload.php is in a subdirectory called phpmailer.

    Is it?

    If not, fix the path so you script can find the PHPMailerAutoload.php file.

    Thanked by 12014
  • Please disable the API key you have posted here "$mail->Password = 'WJFu-3T1GFYS-17zTGGsA'; " in Mandrill. Some else can use it and you might get into trouble.

    Disable and create a new one............

    @2014 said:
    Verelox and sdglhm Here is code im using

     <?php
    >         require('phpmailer/PHPMailerAutoload.php');
    >         
    >         $mail = new PHPMailer;
    >         //$mail->SMTPDebug = 1;                               // Enable verbose debug output
    >         
    >         $mail->IsSMTP();                                      // Set mailer to use SMTP
    >         $mail->Host = 'smtp.mandrillapp.com';                 // Specify main and backup server
    >         $mail->Port = 587;                                    // Set the SMTP port
    >         $mail->SMTPAuth = true;                               // Enable SMTP authentication
    >         $mail->Username = '[email protected]';                // SMTP username
    >         $mail->Password = 'WJFu-3T1GFYS-17zTGGsA';                  // SMTP password
    >         $mail->SMTPSecure = 'tls';                            // Enable encryption, 'ssl' also accepted
    >         
    >         $mail->From = '[email protected]';
    >         $mail->FromName = 'Your From name';
    >         $mail->AddAddress('[email protected]', 'Josh Adams');  // Add a recipient
    >         $mail->AddAddress('[email protected]');               // Name is optional
    >         
    >         $mail->IsHTML(true);                                  // Set email format to HTML
    >         
    >         $mail->Subject = 'Here is the subject';
    >         $mail->Body    = 'This is the HTML message body in bold!';
    >         $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
    >         
    >         if(!$mail->Send()) {
    >            echo 'Message could not be sent.';
    >            echo 'Mailer Error: ' . $mail->ErrorInfo;
    >            exit;
    >         }
    >         
    >         echo 'Message has been sent';
    >         ?>
        
    
    Thanked by 12014
  • 20142014 Member

    @sleddog said:

    i have fixed that problem... This same settings working in shared Host :) but not working in my New VPS host

  • 20142014 Member
    edited July 2015

    @bytechef Tahnk you for reply.. don't worry i have put Wrong password and username :)

    Thanked by 1logixmedia
  • ClouviderClouvider Patron Provider, Veteran

    Googled similar issues with the resolution (regarding path)

    http://community.sitepoint.com/t/phpmailer-require-fatal-error/191448/21

  • 2014 said: i have fixed that problem... This same settings working in shared Host :) but not working in my New VPS host

    So is it working now or not? If not, what is the error?

  • 2014 said: This same settings working in shared Host :) but not working in my New VPS host

    ->

    century1stop said: dkim and spf setup

    Have you configured the Dkim and SPF

  • 20142014 Member

    @sleddog said:

    Dear " " Fatal error: require(): Failed opening required " " The problem is solved now... But now showing " Message could not be sent.Mailer Error: SMTP connect() failed. "

  • 20142014 Member

    @sdglhm said:
    Have you configured the Dkim and SPF

    Not yet.. I Don't Know What It Is, but this problem is coming to new host.. Shared Host working this code well and when i refresh page email is going to inbox.. but not working for VPS :(

  • I am sure you might have done most of the troubleshooting listed in the following page, if not try some of them:

    https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

    Especially set the smtp debug mode to 3 or 4...

    @2014 said:
    Not yet.. I Don't Know What It Is, but this problem is coming to new host.. Shared Host working this code well and when i refresh page email is going to inbox.. but not working for VPS :(

  • 20142014 Member

    @bytechef @sdglhm @sleddog @Clouvider Thank you for help.. i think host SMTP my own host...i already bought VPS for it but i don't know how i setup..

  • ClouviderClouvider Patron Provider, Veteran

    @2014 managing your mail server is not only about setting it up. Use Mandrill if you have no prior experience with that.

    Thanked by 12014
  • shared hosting comes with mail server? ;P

    Thanked by 12014
  • 20142014 Member

    @Clouvider said:
    2014 managing your mail server is not only about setting it up. Use Mandrill if you have no prior experience with that.

    Thanks.. but i don't know how to fix " Message could not be sent.Mailer Error: SMTP connect() failed. "

  • He is using Mandrill as I see there

    $mail->Host = 'smtp.mandrillapp.com';

    @Clouvider said:
    2014 managing your mail server is not only about setting it up. Use Mandrill if you have no prior experience with that.

    Thanked by 12014
  • 20142014 Member

    @century1stop said:
    shared hosting comes with mail server? ;P

    i don't know, but i host all phpmailer file to my shared host... and its working :)

  • 20142014 Member

    @bytechef said:
    He is using Mandrill as I see there

    $mail->Host = 'smtp.mandrillapp.com';

    Yes.. After i moved all files to new host, this error coming

  • century1stopcentury1stop Member
    edited July 2015

    guess you probably need a mail server, vps doesn't have it out of the box, only sendmail ;)
    did your host block port 25?

  • logixmedialogixmedia Member
    edited July 2015

    Then you should be using the Mandrill API....

    Follow the instructions in this link:

    https://mandrillapp.com/api/docs/index.php.html

    I have done this couple of times and works neat....

    Created a function as follows:

    function mandrill_mail() {
    
            require_once('vendors/mandrill/Mandrill.php'); this should point to the location of the Mandrill file
    
                    try {
                            $mandrill = new Mandrill('jd_dfsdf_sdVFEQ'); // API key
    
                            $message = array(
                                'html' => '<p>Something goes here</p>',
                                'text' => 'Some text',
                                'subject' => 'Subject text',
                                'from_email' => '[email protected]',
                                'from_name' => 'Senders name',
                                'to' => array(
                                    array(
                                        'email' => '[email protected]',
                                        'name' => 'Receivers name',
                                        'type' => 'to'
                                    )
                                )
    
    
                            );
    
                            $result = $mandrill->messages->send($message);
                            if ($result) {
                                $_SESSION['success'] = "It will be approved after verification.";
                                header('location: success.php');
                            }
    
                    } catch(Mandrill_Error $e) {
                        // Mandrill errors are thrown as exceptions
                        echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage();
                        // A mandrill error occurred: Mandrill_Unknown_Subaccount - No subaccount exists with the id 'customer-123'
                        throw $e;
                    }
    
        }
    
    Thanked by 12014
  • 20142014 Member

    @bytechef said:

    I have Removed " $mail->IsSMTP(); " line, now showing " Message has been sent " but now coming any message for my mail

  • 20142014 Member
    edited July 2015

    @bytechef Here is error Logs

        [Wed Jul 22 19:31:37.891370 2015] [access_compat:error] [pid 1122] [client 108.000.000.109:16793] AH01797: client denied by server configuration: /home/mysite/public_html/error_log
        [Wed Jul 22 13:47:01.219947 2015] [core:alert] [pid 23803] [client 173.245.000.000:31912] /home/mysite/public_html/.htaccess: <Directory not allowed here
        [Wed Jul 22 13:46:40.707102 2015] [core:alert] [pid 23806] [client 108.162.000.000:26568] /home/mysite/public_html/.htaccess: <Directory not allowed here, referer: http://mysite/mailer.php
    
Sign In or Register to comment.