$this->cachedImages($random_hash);
- $cachePath = session_save_path() . '/email-cache-' . getenv('APACHE_RUN_USER') . '/mail/' . $this->tableName() . '-' . $this->id . '.body.html';
+ $cachePath = session_save_path() . '/email-cache-' . getenv('APACHE_RUN_USER') . '/mail/' . $this->tableName() . '-' . $this->id . '.txt';
if (!$force && $this->isGenerated($cachePath)) {
return;
mkdir(dirname($cachePath), 0700, true);
}
- $this->processRelacements($replace_links);
-
$fh = fopen($cachePath, 'w');
fwrite($fh, implode("\n", array(
"X-Message-ID: {t.id} "
))."\n");
+ fclose($fh);
+
+ $cachePath = session_save_path() . '/email-cache-' . getenv('APACHE_RUN_USER') . '/mail/' . $this->tableName() . '-' . $this->id . '.body.html';
+
+ if (!file_exists(dirname($cachePath))) {
+ mkdir(dirname($cachePath), 0700, true);
+ }
+
+ $this->processRelacements($replace_links);
+
+ $fh = fopen($cachePath, 'w');
// note the extra space to finish the last line..
fwrite($fh, " " . "