[TYPO3-dev] @file_get_contents($url) returns nothing when running script from cronjob

Brian Bendtsen bb at bellevuevej.dk
Wed Oct 1 13:09:18 CEST 2008


Brian Bendtsen skrev:
> Hi
> 
> I have been working with an extension thats suppose to send html 
> formatted emails to users automatically by using a cronjob.
> 
> there is a script called mailer.sh which works when I run it manually 
> from a command line, but running it from a cronjob it "acts" differently 
> and I think I have found out why.
> 
> When the script is invoked by the cronjob, not all mails are received, 
> looks like the server is sending them though, and the mails that are 
> received has no images.
> 
> I have been doing a lot of debugging in the extension itself without 
> getting any furter, but then I tried debugging the 
> class.t3lib_htmlmail.php I found out the the array 
> $this->theParts['html']['media'] is empty when sending via cronjob and 
> this somehow has to do with the problem.
> 
> If I comment out the lines(666-671):
> 
> --------
>                     $this->add_message("--".$boundary);
>                     $this->add_message('Content-Type: '.$media['ctype']);
>                     $this->add_message('Content-ID: 
> <part'.$key.'.'.$this->messageid.'>');
>                     $this->add_message('Content-Transfer-Encoding: 
> base64');
>                     $this->add_message('');
>                     
> $this->add_message($this->makeBase64($media['content']));
> 
> --------
> 
> All the mails are sent but no images are shown, which is to be expected 
> I guess :)
> 
> Does anybody have an idea about why the media files are "removed" when 
> running the script from a cronjob?
> 
> Where does the array $this->theParts['html']['media'] get its data?
> 
> /Brian Bendtsen

Ok

I have found out that when running script from cronjob the function 
@file_get_contents($url) returns nothing.

Do I need to set a path variable in the mailer.sh script?

Originally this is set in the script:

define('TYPO3_mainDir', 'typo3/');
define('PATH_thisScript',$typopath.'typo3/typo3');
define('TYPO3_MOD_PATH', $modulepath.'/mailer/');

I think the PATH_thisScript looks strange, it doesn't make much sence to 
  me since the path is not the correct path to the script. However 
chaging it to something like this:

define('PATH_thisScript',$typopath.'typo3conf/ext/aux_newsmailer/mailer/'); 
(which would be the correct path)

I get this error:

Error in init.php: Path to TYPO3 main dir could not be resolved 
correctly. <br /><br /><font color="red"><strong>This happens if the 
last 6 characters of this path, 
/var/www/typo3/dev.efb.dk/typo3conf/ext/aux_newsmailer/mailer/ 
($temp_path), is NOT "typo3/" for some reason.<br />
		You may have a strange server configuration.
		Or maybe you didn't set constant TYPO3_MOD_PATH in your 
module?</strong></font><br /><br />If you want to debug this issue, 
please edit typo3/init.php of your TYPO3 source and search for the die() 
call right after this line (search for this text to find)...


/Brian




More information about the TYPO3-dev mailing list