Skip to content
On this page

Getting Started

Using Usend to send emails is super easy. You can quickly set up your project, write a piece of code, and deploy it seamlessly. Let's take a look at the basic usage of Usend.

Starting in a Few Steps

By providing your domain and administrative email, you can proceed with the setup and configuration specific to your domain for an optimal Usend experience.

1. Install

Usend is available as an npm package. You can install it using the following command:

bash
npm install usend-email

With the simple configuration outlined below, you will be ready to utilizing Usend for sending emails in no time.

2. Add SPF record

To start sending emails, it's essential to have your own domain. With your domain active at a domain registrar, the first step is to list MailChannels' servers (find out more about MailChannels here) as legitimate for email transmission. To do this, you should add an SPF (Sender Policy Framework) record to your DNS settings.

So, access your DNS provider and add a TXT record with the following details:

Name
Type
Content
example.com TXT v=spf1 a mx include:relay.mailchannels.net ~all

And just replace example.com with your actual domain name.

3. Add Domain Lockdown™ record

Now, to authorize Usend to send emails on behalf of your domain, you need to use Domain Lockdown™. To do this, add a TXT record with the following details:

Name
Type
Content
_mailchannels.example.com TXT v=mc1 cfid=usend.email

By adding this DNS TXT record, you indicate a list of allowed senders to send email from your domain. Any other sender attempting to send from your domain will have their emails bounced with an error. This provides an additional layer of security and control over sending email from your domain.

4. Send email using HTML

With Usend, you can easily send emails with HTML content, allowing you to create visually appealing and dynamic email messages. To send an email with HTML content, follow these steps:

  1. Construct your email message using HTML markup, including formatting, styles, images, and links.

  2. In your Usend code, specify the HTML content of the email using the html parameter when calling the sendEmail method.

    ts
    await usend.sendEmail({
      from: "[email protected]",
      to: "[email protected]",
      subject: "Hello from Usend",
      html: "<h1>Welcome to Usend</h1><p>This is a sample email sent using Usend.</p>",
    });

    Customize the from, to, subject, and html values as per your requirements.

  3. Execute your code, and Usend will handle the process of sending the email with the specified HTML content.

By incorporating HTML into your emails, you can create visually rich and engaging content to make your messages more impactful and effective. You also can utilize React to create dynamic email content.

While you can already start sending emails with Usend, we recommend taking more steps to protect your domain from unauthorized usage. This ensures that your domain remains secure and prevents anyone from impersonating you and sending emails on your behalf. To learn how to implement additional safeguards for your domain in just a few simple steps, refer to the documentation. Safeguarding your domain will provide an extra layer of security and peace of mind.