Messaging

Mailgun

Send emails to your Nuvix users using Mailgun and Nuvix Messaging.

Mailgun lets you send customized email messages to your users. These emails can be sent immediately or scheduled. You can send emails for purposes like reminders, promotions, announcements, and even custom authentication flows.

Add provider

To add Mailgun as a provider, navigate to Messaging > Providers > Add provider > Email.

Add Mailgun provider configuration

Give your provider a name > choose Mailgun > click Save and continue. The provider will be saved to your project, but not enabled until you complete its configuration.

Configure provider

In the Configure step, you will need to provide details from your Mailgun dashboard to connect your Nuvix project.

Configure Mailgun provider settings

You will need to provide the following information from your Mailgun dashboard.

Field nameDescription
API keyHead to Profile -> API Security -> Add new key.
DomainHead to Sending -> Domains -> Add new domain. Follow Mailgun's instructions to verify the domain name.
EU regionEnable the EU region setting if your domain is within the European Union.
Sender emailThe provider sends emails from this sender email. The sender email needs to be an email under the configured domain.
Sender nameThe sender name that appears in the emails sent from this provider.
Reply-to emailThe reply-to email that appears in the emails sent from this provider. The reply-to email needs to be an email under the configured domain.
Reply-to nameThe reply-to name that appears in the emails sent from this provider.

After adding the following details, click Save and continue to enable the provider.

Test provider

Before sending your first message, make sure you've configured a topic and a target to send messages to.

To send a test message, navigate to Messaging > Messages > Create message > Email.

Create email message interface

Add your message and in the targets step, select one of your test targets. Set the schedule to Now and click Send.

Verify that you can receive the message in your inbox. If not, check for logs in the Nuvix Console or in your provider's logs.

To send a message programmatically, use the Nuvix Server SDK.

import { Client } from '@nuvix/client';

const nx = new Client()
  .setEndpoint('https://api.nuvix.in/v1')
  .setProject('<PROJECT_ID>')
  .setKey('<API_KEY>');

const message = await nx.messaging.createEmail({
  messageId: '<MESSAGE_ID>',
  subject: '<SUBJECT>',
  content: '<CONTENT>'
});

You can follow the Send email messages journey to send your first email and test your provider.

Manage provider

You can update or delete a provider in the Nuvix Console.

Navigate to Messaging > Providers > click your provider. In the settings, you can update a provider's configuration or delete the provider.

To update or delete providers programmatically, use the Nuvix Server SDK.

import { Client } from '@nuvix/client';

const nx = new Client()
  .setEndpoint('https://api.nuvix.in/v1')
  .setProject('<PROJECT_ID>')
  .setKey('<API_KEY>');

// update provider
const provider = await nx.messaging.updateMailgunProvider(
  '<PROVIDER_ID>',
  '<PROVIDER_NAME>',
  '<API_KEY>',
  '<DOMAIN>',
  '<IS_EU_REGION?>',
  '<SENDER_NAME>',
  '<SENDER_EMAIL>',
  '<REPLY_TO_NAME>',
  '<REPLY_TO_EMAIL>',
  '<ENABLED?>'
);

// delete provider
await nx.messaging.deleteProvider('<PROVIDER_ID>');

How is this guide?

Last updated on

Mailgun