Skip to content

Bulk Email

You can send newsletters or service mail to your users by sending your email to the endpoint email address. The following example shows the format for email endpoints for sending newsletters:

xxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@mail.skapi.com

Go to Bulk Email page, select the email type, and the page will show the email endpoint address to send the newsletter.

Sending Public Newsletters

You can send public newsletters to your users by sending your email to the endpoint email.

First, the users must subscribe to the public newsletter to receive your public newsletters:

html
<form onsubmit="skapi.subscribeNewsletter(event).then(res => alert(res))">
    <input type="email" name="email" placeholder='your@email.com'/>
    <input hidden name="redirect" value="https://your.domain.com/successpage"/>
    <input hidden name="group" value="public"/>
    <input type="submit" value="Subscribe"/>
</form>
js
skapi.subscribeNewsletter({
    email: 'users@email.com',
    redirect: 'https://your.domain.com/successpage',
    group: 'public'
}).then(res => alert(res));

The example above shows how to let your visitors subscribe to the public newsletter by calling subscribeNewsletter().

When the request is successful, user will receive a confirmation email to verify their email address. User can confirm their email address by clicking the link in the email. If the confirmation is successful, the user will be redirected to the redirect url provided in the subscribeNewsletter() parameter.

All the public newsletters will have unsubscribe link at the bottom of the email. When the user clicks the unsubscribe link, they will no longer receive your public newsletters.

For more detailed information on all the parameters and options available with the subscribeNewsletter() method, please refer to the API Reference below:

subscribeNewsletter(params, callbacks):Promise<string>

WARNING

If the user is logged in, they will not be asked to confirm their email address. Instead, they must have their email verifed.

Sending Service Mail

You can send service mail to your users with an account. To subscribe to service mails the user must be logged in. Service mail can be useful to send information, notifications, and other service-related emails.

First, user must subscribe to the service newsletter to receive the email.

WARNING

  • User must be logged in to subscribe to your service newsletters.
  • User must have their email verified to subscribe to your service newsletters.
html
<form onsubmit="skapi.subscribeNewsletter(event).then(res => alert(res))">
    <input hidden name="group" value="authorized"/>
    <input type="submit" value="Subscribe"/>
</form>
js
skapi.subscribeNewsletter({
    group: 'authorized'
}).then(res => alert(res));

The example above shows how to let your visitors subscribe to the service mail by calling subscribeNewsletter().

Requesting Newsletter Endpoint for Admins

The adminNewsletterRequest() method allows administrators to request a personalized email endpoint for sending newsletters. Only users with administrator privileges (access group 99) can request this endpoint.

To send newsletters, an admin must first request a personalized endpoint using adminNewsletterRequest(). This method verifies admin privileges and returns a unique URL for sending emails.

js
skapi.adminNewsletterRequest().then(response => {
    console.log("Your newsletter endpoint:", response)});

WARNING

This endpoint is specific to the requesting admin and can only receive emails from the admin’s registered email address.

Checking if the user is subscribed to the service mail

You can let the user check if they have subscribed to the service mail by calling getNewsletterSubscription().

js
skapi.getNewsletterSubscription({
    group: 'authorized'
}).then(subs => {
    if (subs.length) {
        // user is subscribed to the service newsletter
    }
    else {
        // no subscription
    }
})

Unsubscribing from the service mail

You can let the user unsubscribe from the service newsletter by calling unsubscribeNewsletter().

js
skapi.unsubscribeNewsletter({
    group: 'authorized'
}).then(res => {
    // user is unsubscribed from the service newsletter
})

Fetching Sent Emails

You can fetch sent emails from the database by calling getNewsletters(). By default, it fetches all the public newsletters from the database in descending timestamp.

In the newsletter object, the url is the URL of the html file of the newsletter. You can use the URL to fetch the newsletter content.

js
skapi.getNewsletters().then(newsletters => {
    // newsletters.list is an array of newsletters
    /*
    {
        message_id: string; // Message ID of the newsletter
        timestamp: number; // Timestamp of the newsletter
        complaint: number; // Number of complaints
        read: number; // Number of reads
        subject: string; // Subject of the newsletter
        bounced: string; // Number of bounces
        url: string; // URL of the newsletter
    }  
    */
})

For more detailed information on all the parameters and options available with the getNewsletters() method, please refer to the API Reference below:

getNewsletters(params, options?): Promise<DatabaseResponse<Newsletter>>

Fetching Sent Emails with Conditions

You can fetch sent emails from the database with conditions by calling getNewsletters().

Below is an example of fetching service mails that are sent to the service users before 24 hours ago in descending order.

For full parameters and options, see getNewsletters(params, options?).

js
skapi.getNewsletters({
    searchFor: 'timestamp',
    value: Date.now() - 86400000, // 24 hours ago
    condition: '<',
    group: 'authorized',
}, { ascending: false }).then(newsletters => {
    // newsletters.list is an array of newsletters
    /*
    {
        message_id: string; // Message ID of the newsletter
        timestamp: number; // Timestamp of the newsletter
        complaint: number; // Number of complaints
        read: number; // Number of reads
        subject: string; // Subject of the newsletter
        bounced: string; // Number of bounces
        url: string; // URL of the newsletter
    }  
    */
})