Docs Designs & email types

Designs & email types

Register custom email types with hooks

On this page

FreddyMail groups messages by email type. Core types such as password_reset, new_user and admin_notification are built in. For your own plugins or integrations, register additional types through the WordPress filter freddymail_register_email_type.

A custom type is useful when an email fires regularly and should later get its own template, SMTP profile or log diagnostics. Typical examples are booking confirmations, course access emails, form confirmations, license notices or internal admin alerts.

Minimal example

Put this code in your own plugin or in a small must-use plugin. Do not put it in the theme when the email belongs to a business process.

<?php
/**
 * Plugin Name: My Booking FreddyMail Types
 */

add_filter('freddymail_register_email_type', function (array $types): array {
    $types[] = [
        'id' => 'booking_confirmation',
        'label' => __('Booking confirmation', 'my-booking'),
        'description' => __('Sent after a customer completes a booking.', 'my-booking'),
        'source' => 'plugin',
        'category' => 'transactional',
        'placeholders' => [
            'customer_name' => __('Customer name', 'my-booking'),
            'booking_id' => __('Booking ID', 'my-booking'),
            'booking_date' => __('Booking date', 'my-booking'),
        ],
        'placeholder_samples' => [
            'customer_name' => 'Jane Doe',
            'booking_id' => 'BK-1042',
            'booking_date' => '2026-05-13',
        ],
        'fallback_subject' => __('Your booking is confirmed', 'my-booking'),
        'default_body_html' => '<p>Hello {{customer_name}}, your booking {{booking_id}} is confirmed for {{booking_date}}.</p>',
        'allow_resend' => true,
    ];

    return $types;
});

Fields

  • id is the technical ID. Use lowercase letters, numbers, underscores and hyphens only. The ID must be unique.
  • label is the visible name in FreddyMail.
  • description tells the admin when this mail is triggered.
  • source is plugin or custom for your own types. core is reserved for FreddyMail’s built-in types.
  • category may be transactional, system, notification, woocommerce or other.
  • placeholders describes template placeholders available for this type.
  • placeholder_samples provides example values for previews and tests.
  • fallback_subject is used when no custom subject is stored.
  • default_body_html is a safe starting body when no template has been assigned yet.
  • allow_resend should be false for one-time links, 2FA codes or security-sensitive tokens.

Test the registration

  1. Activate the plugin or MU plugin.
  2. Open FreddyMail > Email types and search for your label.
  3. Open the type and verify that placeholders and sample values are visible.
  4. Assign a template or consciously accept the system fallback.
  5. Trigger the real event, for example by creating a test booking.
  6. Open FreddyMail > Logs and verify that the log entry carries the new type.

If the type is quarantined

FreddyMail validates every registration. Invalid entries are not used for production delivery; they are marked as not sendable instead. Common causes:

  • The id is missing or contains unsupported characters.
  • The label is missing.
  • source is not one of core, plugin or custom.
  • Another extension registered the same id. The first registration wins.

Fix the code, reload the admin and check the list again. Trigger a real email only after the type is active.

Connect the type to delivery

Registration makes the type known to FreddyMail. Your own plugin still needs to trigger the actual message. If your plugin already uses wp_mail(), FreddyMail can log the delivery; the type mapping depends on the context your plugin or FreddyMail integration provides during the send.

For production integrations, use this order: register the type, trigger the delivery, then inspect the log. That immediately shows whether template, recipient, subject and provider response line up.