i'm running a php script that uses file_get_contents in order to mail a list with what it's inside that remote file. If i run the script manually everything works fine, but when i leave it and wait for the cron to run it doesn't get that remote content..... Is that possible? i copy here a bit of the code where i think the problem is:
$flyer = file_get_contents('flyer.html');
$desti = $firstname." ".$lastname;
$mail = new phpmailer();
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "orion.xxxx.com"; // line to be changed
$mail->Port = 465; // line to be changed
$mail->Username = '[email protected]'; // line to be changed
$mail->Password = 'xxxx90'; // line to be changed
$mail->FromName = 'Bob'; // line to be changed
$mail->From = '[email protected]';// line to be changed
$mail->AddAddress($email, $desti);
$mail->Subject = 'The Gift Store'; // to be changed
if ($cover_form == '1'){ $mail->MsgHTML($long10);} else
if ($cover_form == '2'){ $mail->MsgHTML($customer);} else
if ($cover_form == '3'){ $mail->MsgHTML($freedoers);} else
if ($cover_form == '4'){ $mail->MsgHTML($freelongform);} else
if ($cover_form == '5'){ $mail->MsgHTML($freestoreshort);} else
if ($cover_form == '6'){ $mail->MsgHTML($getasiteshort);} else
if ($cover_form == '7'){ $mail->MsgHTML($flyer);}
else {}
The cron doesn't load the code from the 'folder' you are in, so you will need to specify a full path
$flyer = file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . "flyer.html");
The path of the file is different when the cron executes
Try
$flyer = file_get_contents(__DIR__ . '/flyer.html');
Or specify the path yourself
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With