diff --git a/message/output/airnotifier/requestaccesskey.php b/message/output/airnotifier/requestaccesskey.php
index 90f397c7f92..fe33a5559ed 100644
--- a/message/output/airnotifier/requestaccesskey.php
+++ b/message/output/airnotifier/requestaccesskey.php
@@ -59,6 +59,8 @@ if (strpos($CFG->airnotifierurl, message_airnotifier_manager::AIRNOTIFIER_PUBLIC
     }
 }
 
+echo $OUTPUT->header();
+
 $manager = new message_airnotifier_manager();
 $warnings = [];
 
@@ -107,6 +109,5 @@ foreach ($warnings as $warning) {
 
 $msg .= $OUTPUT->continue_button($returl);
 
-echo $OUTPUT->header();
 echo $OUTPUT->box($msg, 'generalbox ');
 echo $OUTPUT->footer();