[ 'height' => '400px', 'params' => [ 'message' => ['Message', '
Hello there. This is a sample email body.
'], 'color' => ['State', 'success'] ] ], \Common\Mailer::TEMPLATE_VERIFY_EMAIL => [ 'height' => '550px', 'params' => [ 'url' => ['Verification URL', APP_URL.'/php_verifications_verify.php?action=validate&key='.hash('sha256', token())], 'name' => ['Name', 'Someone'] ] ], \Common\Mailer::TEMPLATE_2FA_CODE => [ 'height' => '500px', 'params' => [ 'code' => ['Code', random_int('111111', '999999')], 'name' => ['Name', 'Someone'] ] ] ]; if (is_post()) { try { $template = get('template', $_POST); $email = get('email', $_POST); $body = \Common\Mailer::formatBody($_POST, $template); $mailer = new \Common\Mailer; $result = $mailer->submit($email, 'Test email template: '.$template, $body); if ($result) { $query = http_build_query($_POST); redirect(APP_URL.'/php_mailer_templates.php?success=1&'.$query.'#mailer-template-'.$template); } else { throw new \Exception('Failed to deliver message. Please make sure your.env file is configured correctly');
}
} catch (Exception $ex) {
$exception = $ex->getMessage();
}
}
?>