DocumentationSDK on GitHub

Documentation Guides

Connect test emails

Connect the editor’s test action to your application’s delivery provider.

On this page

Handle the test action

Pass onTestEmail when mounting the editor. Forward the request to your backend and resolve the callback only after your provider accepts the submission. Reject on failure so the editor can show the error.

typescript
import { mount } from '@weavour/editor';

const editor = mount('#email-editor', {
  editorKey: 'YOUR_PUBLIC_EDITOR_KEY',
  userId: 'user-123',
  async onTestEmail(request) {
    const response = await fetch('/api/test-email', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      // Includes display conditions when the email uses them.
      body: JSON.stringify(request),
    });
    if (!response.ok) throw new Error('Test email could not be sent.');
  },
  onError: console.error,
});

Implement your backend route

/api/test-email is an example route in your application. Authenticate the caller, validate the recipient and content, and send with server-side provider credentials. Weavour does not send the test for you.

Use test recipient values

The callback includes literal tokens and, for conditional emails, displayConditions and requiresConditionEvaluation. Resolve personalization on your backend before sending. Preview samples are not recipient values.

Hide the built-in test action

Set enableTestEmail: false at mount or call updateConfig({ enableTestEmail: false }). You can keep your own test-email action in the host application.

Need help? Contact us