options['recipient'] ?? ''; if (!is_string($to)) { return false; } if (trim($to) === '') { $to = $settings['email']['value'] ?? null; } if (!is_string($to) || filter_var($to, FILTER_VALIDATE_EMAIL) === false) { return false; } $subject = $this->options['subject'] ?? ''; if (!is_string($subject)) { return false; } if (trim($subject) === '') { $subject = 'Form submission: '.$this->getFormName(); } if (strpbrk($subject, "\r\n") !== false) { return false; } $message = $this->getNiceFields(); $mailer = phpb_instance('mail'); return $mailer !== null && $mailer->send($to, $subject, $message) === true; } private function getNiceFields(): string { $text = ''; foreach ($this->getFormFields() as $field) { $name = $field['name'] ?? ''; $label = $field['label'] ?? $name; $value = $this->getEntryFields()[$name] ?? ''; if (is_array($value)) { $value = implode(', ', array_map('strval', $value)); } elseif (!is_scalar($value)) { $value = ''; } $text .= $label . ': ' . $value . "\n"; } return $text; } }