Skip to content

Email System

Doggy's email system is built on Symfony Mailer, supporting multi-mailbox configuration, template management, and async sending.

Overview

Key files:

FileDescription
src/Service/MailService.phpEmail sending service
src/Service/Security/EmailHtmlSanitizer.phpHTML security filter
src/Entity/System/EmailConfig.phpMailbox configuration
src/Entity/System/EmailTemplate.phpEmail template
src/Entity/System/EmailLog.phpSend log
src/Entity/System/EmailFunctionBinding.phpFunction binding

Admin controller: App\Controller\Admin\EmailConfigController

Email Templates

Templates are stored in the database (EmailTemplate entity) with visual editing support:

Template directory: templates/admin/email/

  • editor.html.twig: Template editor
  • index.html.twig: Template list
  • preview.html.twig: Template preview

Sending Email

Send via MailService:

php
use App\Service\MailService;

class NotificationService
{
    public function __construct(private MailService $mailService) {}

    public function sendWelcome(Employee $employee): void
    {
        $this->mailService->send(
            to: $employee->getEmail(),
            subject: 'Welcome to Doggy',
            template: 'welcome',
            params: [
                'name' => $employee->getName(),
            ]
        );
    }
}

HTML Security

EmailHtmlSanitizer filters HTML content before sending:

  • Removes script, iframe, object and other dangerous elements
  • XSS injection prevention
  • Protects recipient security

Function Binding

EmailFunctionBinding links email capabilities with system events for automated sending:

  • Password reset emails
  • Account activation notifications
  • System alert notifications

Configuration

yaml
# config/packages/mailer.yaml
framework:
  mailer:
    dsn: '%env(MAILER_DSN)%'

Open Source under MIT | Copyright © 2026 Doggy