diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index aa366c31b2f..91a6bb5ec0e 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -1047,7 +1047,7 @@ class FormMail extends Form
if ($this->withfckeditor) {
$out .= $this->getModelEmailTemplate();
}
- if (isModEnabled('ai')) {
+ if ($this->withaiprompt && isModEnabled('ai')) {
$out .= $this->getSectionForAIPrompt();
}
$out .= '';
@@ -1438,7 +1438,7 @@ class FormMail extends Form
*
* @return string Text for instructions
*/
- public function getSectionforAIPrompt()
+ public function getSectionForAIPrompt()
{
global $langs;