diff --git a/classes/dkim_manager.php b/classes/dkim_manager.php index a20c34a..e6c514f 100644 --- a/classes/dkim_manager.php +++ b/classes/dkim_manager.php @@ -101,7 +101,7 @@ public function get_domain_path() { public function get_base_path($create = false) { $certdir = $this->get_domain_path(); if ($create) { - mkdir($certdir, 0777, true); + @mkdir($certdir, 0777, true); } return $certdir . '/' . $this->selector; } @@ -182,6 +182,7 @@ public function get_dns_value() { */ public function get_dns_value_chunked() { + $dnsvalue = ''; $rawvalue = $this->get_dns_value(); // Split into chunks. diff --git a/dkim.php b/dkim.php index e66bed9..7bf262a 100644 --- a/dkim.php +++ b/dkim.php @@ -71,10 +71,17 @@ } $dkimdir = $CFG->dataroot . '/dkim/'; -$domains = scandir($dkimdir, SCANDIR_SORT_DESCENDING); +$domains = []; +if (is_dir($dkimdir)) { + $domains = scandir($dkimdir, SCANDIR_SORT_DESCENDING); +} + $domaincount = 0; $noreplydomain = substr($CFG->noreplyaddress, strpos($CFG->noreplyaddress, '@') + 1); +// Always make sure the noreply domain is included even if nothing has been setup yet. +$domains = array_unique(array_merge($domains, [$noreplydomain])); + print $OUTPUT->header(); print $OUTPUT->heading(get_string('dkimmanager', 'tool_emailutils')); @@ -85,7 +92,7 @@ if (substr($domain, 0, 1) == '.') { continue; } - if (!is_dir($dkimdir . $domain)) { + if (!is_dir($dkimdir . $domain) && $domain != $noreplydomain) { continue; } @@ -110,10 +117,20 @@ $url = new moodle_url('https://mxtoolbox.com/SuperTool.aspx', ['action' => "txt:$domain"]); print "