sebech
sebech

Reputation: 17

PHPMailer warnings

I am currently gobsmacked and so ridiculously confused at the stupidity of this error. It honestly makes no sense to me.

So I have a network of 4 websites all using the same contact.php script which is pasted blow.

So on three of the sites, the script works perfectly. However on one of the sites, it keeps popping up errors. There shouldn't be any errors at all since they are on the same server and using exact same html files except for different content.

Warning: include(../../vip/boss/mailer/class.phpmailer.php) [function.include]: failed to open stream: No such file or directory in /home/aap/public_html/justevents.net.au/quickcontact.php on line 2

Warning: include(../../vip/boss/mailer/class.phpmailer.php) [function.include]: failed to open stream: No such file or directory in /home/aap/public_html/justevents.net.au/quickcontact.php on line 2

Warning: include() [function.include]: Failed opening '../../vip/boss/mailer/class.phpmailer.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/aap/public_html/justevents.net.au/quickcontact.php on line 2

Warning: include(../../vip/boss/mailer/class.smtp.php) [function.include]: failed to open stream: No such file or directory in /home/aap/public_html/justevents.net.au/quickcontact.php on line 3

Warning: include(../../vip/boss/mailer/class.smtp.php) [function.include]: failed to open stream: No such file or directory in /home/aap/public_html/justevents.net.au/quickcontact.php on line 3

Warning: include() [function.include]: Failed opening '../../vip/boss/mailer/class.smtp.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/aap/public_html/justevents.net.au/quickcontact.php on line 3

Fatal error: Class 'PHPMailer' not found in /home/aap/public_html/justevents.net.au/quickcontact.php on line 27

Please Help Me

<?php
include("../../vip/boss/mailer/class.phpmailer.php");
include("../../vip/boss/mailer/class.smtp.php");
function heal($str) {
$injections = array('/(\n+)/i',
'/(\r+)/i',
'/(\t+)/i',
'/(%0A+)/i',
'/(%0D+)/i',
'/(%08+)/i',
'/(%09+)/i'
);
$str= preg_replace($injections,'',$str);
return str_replace('@','-AT-',$str);
} 
$name = heal($_POSTname);
$email = str_replace('-AT-','@',heal($_POSTemail));
$message = heal(str_replace("\n",'<br>',$_POSTmessage));
$category = heal($_POSTcategory);
if(substr_count($email,'@')==1){
$mail=new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth   = true;                
$mail->Host       = "localhost";  
$mail->SMTPSecure = "ssl";     
$mail->Port       = 465;   
$mail->Username   = "[email protected]";  
$mail->Password   = "REDACTED";          
$mail->From       = "[email protected]";
$mail->FromName   = $name;
$mail->Subject    = $category.' Enquiry';
$mail->Body       = $message;           
$mail->WordWrap   = 50;
$mail->AddAddress("[email protected]","justevents. Enquiry");
$mail->AddReplyTo($email,$name);
$mail->IsHTML(true);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
}else{
header("LOCATION:quicksuccess.html");
} 
}else{
echo 'There was an error, please try again. '.substr_count($email,'@');
} 
?>

Upvotes: 1

Views: 5168

Answers (2)

Frankie
Frankie

Reputation: 25165

Use getcwd() on the calling file to debug this sort of errors.

As you can tell by the logs the documents are not in the path they were expected to be.
There is only one way to be sure, use an absolute path.

And then debug the situation with getcwd()...

Upvotes: 2

kratenko
kratenko

Reputation: 7592

Obviously the files you try to include can not be found. So the question is not only if you use the same php script in all four of them, but are they in the same directory? If not, do they have the same directory structure above them? You are using relative paths there for your include, so I guess you just have this version in a subdir or something, so it can not find the files to include from its working directory.

Upvotes: 1

Related Questions