Jump to content

Recommended Posts

Hi guys,

 

I am pulling my hair out here, for some reason this code is ALWAYS giving me the file not found error, even though i have checked the file destination manually and it exists! This is the part of the script giving me a headache;

 

if (!isset($dest_email) || !$dest_email) {
	$xls->send($filename);
} else {
	if (file_exists($dir . $filename)) {
		//Connect to localhost on port 25
		$swift =& new Swift(new Swift_Connection_SMTP("localhost"));
		$message =& new Swift_Message("Non Stock Sales Report");
		$message->attach(new Swift_Message_Part("The file you requested has been attached to this email."));

		//Use the Swift_File class
		$message->attach(new Swift_Message_Attachment(
			new Swift_File($dir . $filename), "$filename", "application/xls"));

		if ($swift->send($message, "$dest_email", "webserver@#####")) {
			echo 'Your email sent succesfully.';
		} else {
			echo 'ERROR - Your email was unsuccessful.';
		}
		$swift->disconnect();
		sleep(5);
		unlink($dir . $filename);
	} else {
		echo 'ERROR - '. $filename .' was not found, try again later.';
	}
}

 

Any help would be appreciated.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/55227-solved-file_exists-problem/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.