class CRM_Member_Form_Task_Email extends CRM_Member_Form_Task {
use CRM_Contact_Form_Task_EmailTrait;
+ /**
+ * Only send one email per contact.
+ *
+ * This has historically been done for contributions & makes sense if
+ * no entity specific tokens are in use.
+ *
+ * @return bool
+ * @throws \CRM_Core_Exception
+ */
+ protected function isGroupByContact(): bool {
+ return !empty($this->getMessageTokens()['membership']);
+ }
+
}