$val) { $content .= "$key: $val\n"; } $content .= "\n" . $message . "\n"; if (is_numeric(CIVICRM_MAIL_LOG)) { $config = CRM_Core_Config::singleton(); // create the directory if not there $dirName = $config->configAndLogDir . 'mail' . DIRECTORY_SEPARATOR; CRM_Utils_File::createDir($dirName); $fileName = md5(uniqid(CRM_Utils_String::munge($fileName))) . '.txt'; file_put_contents($dirName . $fileName, $content ); } else { file_put_contents(CIVICRM_MAIL_LOG, $content, FILE_APPEND); } } }