diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index 49669a4c02c..c54bdab2949 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -627,7 +627,7 @@ class FormMail extends Form
// Add also email aliases from the c_email_senderprofile table
$sql = "SELECT rowid, label, email FROM ".$this->db->prefix()."c_email_senderprofile";
- $sql .= " WHERE active = 1 AND (private = 0 OR private = ".((int) $user->id).")";
+ $sql .= " WHERE active = 1 AND (private = 0 OR private = ".((int) $user->id).") AND entity in getEntity('c_email_senderprofile')";
$sql .= " ORDER BY position";
$resql = $this->db->query($sql);
if ($resql) {