How to run email and SMS notifications on Joomla using the API

In digital marketing, customer communication plays a key role in the success of a business. While email notifications remain a powerful tool, SMS is becoming increasingly important due to its immediacy and high read rates. In this tutorial we will focus on integrating email and SMS notifications in Joomla using API Exsolve and a number of other means.

To begin with, it is important to build the right strategy:

1. Determine the goals and segments of the mailings.

2. Choose the optimal frequency.

3. Adapt content to the interests of the audience.

4. Test headlines, calls, visuals.

5. Continuously measure performance and improve.

Proper work with email can bring a business a significant increase in sales and customers. Therefore, the owner of almost any Joomla website should implement this channel.

Review of Joomla extensions for email notifications

The Joomla extensions catalog has many components for organizing email campaigns. Let's look at some of the most popular and functional options.

AcyMailing

AcyMailing is a well-known component for email marketing in the Joomla ecosystem with an extensive set of functions, a user-friendly interface and support for various email services.

Key features of AcyMailing:

  • Manage an unlimited number of subscriber lists.

  • Detailed segmentation of the database by profile fields.

  • Drag-and-drop email editor.

  • Adaptive templates and content personalization.

  • Scheduled dispatch and autoresponders.

  • Analytics of openings, clicks, unsubscribes.

  • Integration with Joomla, K2, HikaShop, Virtuemart, etc.

There is a free basic version with restrictions on the number of subscribers.

jNews

jNews is another powerful Joomla email marketing solution.

jNews Key Options:

  • Comfortable management of lists and groups of contacts.

  • Visual email editors (WYSIWYG and Drag & Drop).

  • Dynamic content and conditions for its display.

  • Advanced segmentation based on user behavior.

  • Chains of letters, autoresponders, automatic mailings.

  • A/B tests, reports, graphs.

  • Synchronization with Joomla, K2, Easysocial, Jomsocial and more than 30 CMS/CRM.

jNews is available with a subscription starting at $99 per year per domain.

Acajoom

Acajoom is another noteworthy mailing component for Joomla sites. It combines broad functionality with ease of use.

Features of Acajoom:

  • Work with an unlimited number of subscriber lists.

  • Built-in email templates and a simple drag-and-drop editor.

  • Personalization of content by groups and interests.

  • Flexible mailing schedule.

  • Split tests, analytics, reports.

  • Compatible with popular Joomla extensions.

Acajoom price starts at $47 for one site. There is a 30-day money-back guarantee.

You can also mention such extensions as Mailster, Joomla-Mailings, Joomailer, Emclabs Newsletter, etc. Each of them has its own specifics and user audience.

In general, the choice of an email newsletter component depends on the scale of the project, budget and required functions.

Next, we will focus specifically on working with AcyMailing and look at setting up mailings using its example.

Step-by-step instructions for creating a mailing list in AcyMailing

Let's say we have a working Joomla website and we want to launch email marketing on it using AcyMailing.

Let's consider the sequence of necessary actions.

Step 1. Install the component

  • Download the current version of AcyMailing from the developer’s website.

  • In the Joomla admin panel, go to Extensions -> Extension Manager.

  • Click the “Download package file” button and select the downloaded archive from AcyMailing. The component will be installed automatically.

Step 2. General settings

  • Go to Components -> AcyMailing -> Configuration.

  • In the “Basic” tab, fill in the name and email (for the from and reply fields). This data will be used by default when sending emails.

  • In the “Mail Servers” tab, specify the SMTP server, port, login and password for sending letters. This can be SMTP data from your mail service or a connected third party, for example SendGrid, Mailgun.

Step 3: Create a subscriber list

  • In the AcyMailing menu, select Lists.

  • Click the “Create List” button.

  • Specify the name of the list, for example “Main mailing list”.

  • Enter the subject of the subscription confirmation email.

  • Set the “Subscription Confirmation” switch to “Yes”.

  • Save the list.

Step 4: Create a subscription form

  • In the AcyMailing menu, go to forms.

  • Click “Create Form”.

  • Select the list we need in the “Lists” field.

  • We select the subscriber fields that will be displayed in the form, for example, name and email.

  • Copy the generated form code.

Step 5. Inserting the form on the site

  • Creating a new material in Joomla.

  • Switch to the HTML tab of the material editor.

  • Paste the copied subscription form code inside the tags.

  • We publish the material and check that the form is displayed and works correctly.

Step 6. Preparing a letter template

  • In the AcyMailing menu, go to mailings.

  • Click “Create a newsletter”.

  • Specify the subject of the letter.

  • In the “Content” tab, using a convenient drag-and-drop editor, we create the body of the letter.

  • We use personalization, for example Hello, {subscriber name}!

  • Add a call to action and links to the site.

  • We test the display of the letter on different devices in the viewing tab.

Step 7. Test sending

  • In the created mailing, go to the “Sending” tab.

  • In the “Tests” block, enter a test email and click “Send test”.

  • We check the delivery of the letter, the correctness of the content and links.

Step 8. Launch your mailing list

  • In the mailing settings, in the “Sending” tab, select the list of recipients.

  • We specify filters and list segmentation, if necessary.

  • Check the “Published” checkbox.

  • Select the date and time for sending the newsletter.

  • Click “Save and close”.

Thus, the mailing is created and scheduled. After the actual sending to subscribers, in the AcyMailing interface it will be possible to track statistics of opens, clicks, unsubscribes, etc.

This sequence of actions can be repeated to create new mailings on a regular basis.

Personalization and segmentation of mailings

To increase the effectiveness of email marketing, it is not enough to simply send newsletters to your entire subscriber base. It is important to personalize the content of your emails and segment your audience based on various characteristics. Let's look at how this can be implemented using AcyMailing as an example.

Personalization

The AcyMailing editor has personalization tags like {field_name}. These tags are automatically replaced with the appropriate subscriber information when sent.

For example, we have fields first name, last name, gender in the subscriber profile. Then in the text of the letter you can use the following appeals:

Здравствуйте, {firstname}!
Уважаемый {firstname} {lastname},  
Дорогая {firstname},

The AcyMailing template supports almost any conditional construct and loop to implement complex personalization.

In addition, you can filter the database by subscriber activity: opens, clicks, purchases. This will help identify hot and cold segments and make them different in context and intensity of offers.

For example, send a series of reactivation emails to those who have not opened mailings for a long time, and you can make an exclusive offer with a deep discount to the most active subscribers and loyal customers:

Integration of AcyMailing with other Joomla components

Another important advantage of AcyMailing: integration with many other extensions. This allows you to link different data about users on the site and use it to work more efficiently with mailings.

Let's look at a few examples.

Integration with Joomla

Out of the box, AcyMailing can synchronize its subscriber base with built-in Joomla users. To do this you need:

  • Go to Joomla in “Users” -> “Access Groups”.

  • Create a new group, for example “Newsletter Subscribers”.

  • In the AcyMailing menu, go to “Subscribers” -> “User Synchronization”

  • Select “Joomla Groups” as the source.

  • Mark the newly created group “Maillist Subscribers”.

  • Select a mailing list to import users into.

  • Click “Save and Continue.”

Now, when adding a user to the appropriate Joomla group, he will automatically be included in the AcyMailing subscriber database.

Integration with K2

K2 is a popular component for publishing content in Joomla. With the integration enabled, AcyMailing will be able to automatically create mailings from new K2 materials according to specified rules.

Enable integration:

  • In AcyMailing, go to “Extensions” -> “Subscriptions in Joomla”.

  • Opposite line K2, put a checkmark in the “Published” column.

Create an automatic mailing rule:

  • In AcyMailing, go to “Mailmails” -> “Create a mailing list.”

  • In the “Generation” tab, set the “Generate mailing list from K2” switch to “Yes”.

  • We indicate the category or specific K2 materials to be sent.

  • Select a template to automatically create newsletter content.

  • We configure recipient segmentation and filters.

Now, when a new K2 material is published from the specified category, a newsletter will be generated in accordance with the template and automatically sent to subscribers.

Integration with Hikashop and Virtuemart

Hikashop and Virtuemart are popular extensions for organizing an online store on Joomla. Their integration with AcyMailing allows you to use order information for more targeted mailings.

Enabling integration:

  • In the Joomla administrative panel, go to “Components” -> Hikashop/Virtuemart -> “Settings”.

  • Let's go to the integrations section.

  • Opposite the AcyMailing item, check the “Enabled” checkbox.

With a new order in Hikashop or Virtuemart, the buyer’s email will be automatically added to the list of AcyMailing subscribers. In addition, information about the order and purchased goods will be recorded in additional fields.

Here's what the code might look like to generate personalized recommendations based on previous orders in Hikashop:

{foreach $previous_orders as $order}
  {foreach $order->products as $product}
    <li>{$product->name}</li>
  {/foreach}  
{/foreach}

Here we get an array of the user's past orders from Hikashop, go through the products inside each order and display their names in the letter.

In a similar way, you can integrate AcyMailing with many other Joomla components: catalogs, forms, blogs, forums. Information about these integrations is usually contained in the documentation for the corresponding extensions.

Let's look further at how to implement sending SMS on a site running Joomla

Selecting an SMS gateway and connecting it in Joomla

Advantages of SMS notifications:

  • High delivery speed.

  • Guaranteed read (93% of messages are opened within 5 minutes).

  • Personal and confidential nature of the appeal.

  • The ability to reach inactive email subscribers.

  • Reaching an audience that does not use email.

To send SMS from the site, you need to connect to a special service – an SMS gateway. It is a platform that enables messaging between a web application and mobile networks.

There are many gateways with different conditions and capabilities. Some popular options:

When choosing a service, focus on:

  • prices for sending SMS to the countries you need

  • delivery quality

  • API for integration

  • technical support

  • reviews from other users

After analyzing these factors, we register in the service and top up the balance with the initial amount. Next, we will implement the actual connection of the SMS gateway to Joomla. There are two main ways:

1. Through the integration component

In the Joomla extensions catalog you can find ready-made components for working with popular SMS gateways.

We install the component in Joomla, enter the API key from the gateway’s personal account and start sending SMS through the component’s interface, or by calling its functions in the code of other extensions.

Advantages of the approach: ease of integration, minimal labor costs. Cons: less flexibility, dependence on third-party code.

2. Through direct calls to the API

Each gateway provides an HTTP API for sending messages. With an access key, we can directly make requests to the API from Joomla PHP code and process the responses.

Terms and definitions

Before we get into the practicalities, let's familiarize ourselves with some basic terms:

  • ESME (External Short Messaging Entity) is an external application that connects to SMSC to send or receive SMS messages.

  • PDU (Protocol Data Unit) – SMPP protocol data packet.

  • SMSC (Short Message Service Center) – short message service center.

  • TLV (Tag-Length-Value) is a format for presenting additional data in messages.

  • UDH (User Data Header) – user data header in an SMS message.

Connecting to Exolve via SMPP

1. Get access to the developer’s personal account Exsolve.

2. Go to the “Applications” tab in the top menu of your account.

3. Select the desired application.

4. Go to “Messages” → “SMPP account” in the left menu.

5. Write down the following connection parameters: system_id (login), password (password), address (smpp.exolve.ru) and port (2775).

6. Configure your ESME (SMS app) with these settings.

7. Use SMPP protocol version 3.4 to connect.

Sending SMS via Exolve SMPP

1. Select the connection type: receiver or transceiver.

2. When sending SMS, be sure to specify the data_coding parameter:

– Use GSM7 for Latin alphabet

– Use UCS2 for Cyrillic

3. To send via short_message:

– Set the text in the “short_message” field

– For multipart messages use UDH

– Limit: 67 Cyrillic characters or 153 Latin characters per segment

4. To send via payload:

– Set the text in the “payload” field

– Do not divide into segments

– Leave the “short_message” field empty

5. Send enquire_link PDU every 15 minutes to maintain the connection.

Creating a newsletter via the Exolve API

1. Prepare an API key for your Exolve application.

2. Use the connection point: POST https://api.exolve.ru/campaign/v1/Create

3. Set the Authorization header: Bearer {your_API key}

4. Prepare JSON with distribution parameters:

– name: name of the newsletter

– timezone: time zone accounting (true/false)

– Select the distribution channel (sms, voice_message or cascade)

5. For SMS sending, please indicate:

– alpha_name: sender's name

– text: message text

6. For cascade distribution, configure the sequence of channels and transition conditions.

7. If necessary, configure the mailing schedule.

8. Send the request and receive campaign_id in the response.

Example request for SMS text

{
    "name": "test",
    "timezone": true,
    "sms": {
        "props": {
            "alpha_name": "shop",
            "text": "Приходите к нам в магазин!"
        }
    }
}

Example request for cascading mailing

{ 
    "name": "Рассылка с расписанием",
    "cascade": {
        "elements": [
            {
                "sms": {
                    "props": {
                        "alpha_name": "shop",
                        "text": "Приходите к нам!"
                    }
                },
                "condition": "1"
            },
            {
                "voice_message": {
                    "props": {
                        "voice_message_id": "353b86e0-a62c-47d4-9b94-8dba32c922fc",
                        "from": "79991112233"
                    }
                }
            }
        ]
    },
    "schedule": {
        "days": {
            "mon": {
                "intervals": [
                    {
                        "from": {
                            "hours": 10,
                            "minutes": 0,
                            "seconds": 0,
                            "nanos": 0
                        },
                        "to": {
                            "hours": 15,
                            "minutes": 30,
                            "seconds": 0,
                            "nanos": 0
                        }
                    }
                ]
            }
        }
    }
}

Optimizing SMS mailings in Exolve

1. Use GSM7 encoding for messages in Latin to save characters.

2. For Cyrillic, use UCS2 encoding.

3. When sending multipart messages via short_message, form the UDH correctly.

4. For long messages, use payload instead of short_message to avoid manual segmentation.

5. Check your connection regularly by sending enquire_link every 15 minutes.

6. When creating cascading mailings, configure transition conditions to optimize delivery.

7. Use a mailing schedule to send messages at the optimal time for recipients.

Troubleshooting Exolve

1. Use Wireshark to analyze SMPP traffic if problems occur.

2. If you have problems with API requests, check the correctness of the API key and the JSON format.

3. If the mailing list is not created, make sure that:

– Alpha name for SMS belongs to your application

– The phone number for voice SMS belongs to your application

– The voice message ID exists and belongs to your application

4. If there are errors in the parameters, check:

– Alpha name length (from 3 to 11 characters)

– Length of the phone number (from 1 to 14 characters)

– Length of the newsletter name (from 3 to 40 characters)

5. If the mailing does not start at the specified time, check whether you created it during the current schedule interval.

Sending a simple SMS via SMPP

// Подключение к SMPP серверу Exolve
$smpp = new SMPP('smpp.exolve.ru', 2775, 'your_system_id', 'your_password', 'YOUR_SYSTEM_TYPE');
$smpp->bindTransceiver();

// Отправка SMS
$from = 'YOUR_ALPHA_NAME';
$to = '79991234567';
$message="Ваш заказ подтвержден";

$smpp->sendSMS($from, $to, $message, [
    'data_coding' => SMPP::DATA_CODING_UCS2, // Для кириллицы
]);

$smpp->close();

Sending a multipart SMS via SMPP

// Подключение к SMPP серверу Exolve
$smpp = new SMPP('smpp.exolve.ru', 2775, 'your_system_id', 'your_password', 'YOUR_SYSTEM_TYPE');
$smpp->bindTransceiver();

// Отправка составного SMS
$from = 'YOUR_ALPHA_NAME';
$to = '79991234567';
$message="Это длинное сообщение, которое будет разделено на несколько частей. Каждая часть будет отправлена отдельно, но благодаря UDH они будут собраны в одно сообщение на телефоне получателя.";

$parts = str_split($message, 67); // Разделяем на части по 67 символов для кириллицы
$total_parts = count($parts);
$reference_number = mt_rand(0, 255);

foreach ($parts as $i => $part) {
    $udh = pack('cccccc', 5, 0, 3, $reference_number, $total_parts, $i + 1);
    
    $smpp->sendSMS($from, $to, $udh . $part, [
        'data_coding' => SMPP::DATA_CODING_UCS2,
        'esm_class' => SMPP::ESM_CLASS_UDHI,
    ]);
}

$smpp->close();

Creating a cascade mailing via API

$api_key = 'YOUR_API_KEY';
$url="https://api.exolve.ru/campaign/v1/Create";

$data = [
    'name' => 'Каскадная рассылка',
    'timezone' => true,
    'cascade' => [
        'elements' => [
            [
                'sms' => [
                    'props' => [
                        'alpha_name' => 'YourShop',
                        'text' => 'У нас новая акция! Посетите наш сайт для подробностей.'
                    ],
                    'ttl' => '60s'
                ],
                'condition' => '1' // Если SMS не доставлено
            ],
            [
                'voice_message' => [
                    'props' => [
                        'voice_message_id' => 'YOUR_VOICE_MESSAGE_ID',
                        'from' => '79991112233'
                    ]
                ]
            ]
        ]
    ],
    'schedule' => [
        'days' => [
            'mon' => [
                'intervals' => [
                    [
                        'from' => ['hours' => 10, 'minutes' => 0, 'seconds' => 0, 'nanos' => 0],
                        'to' => ['hours' => 18, 'minutes' => 0, 'seconds' => 0, 'nanos' => 0]
                    ]
                ]
            ],
            'tue' => [
                'intervals' => [
                    [
                        'from' => ['hours' => 10, 'minutes' => 0, 'seconds' => 0, 'nanos' => 0],
                        'to' => ['hours' => 18, 'minutes' => 0, 'seconds' => 0, 'nanos' => 0]
                    ]
                ]
            ]
        ]
    ]
];

$headers = [
    'Authorization: Bearer ' . $api_key,
    'Content-Type: application/json'
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
echo "Campaign ID: " . $result['campaign_id'];

Sending SMS using payload

// Подключение к SMPP серверу Exolve
$smpp = new SMPP('smpp.exolve.ru', 2775, 'your_system_id', 'your_password', 'YOUR_SYSTEM_TYPE');
$smpp->bindTransceiver();

// Отправка SMS с использованием payload
$from = 'YOUR_ALPHA_NAME';
$to = '79991234567';
$message="Это длинное сообщение, которое будет отправлено через payload. Оно может содержать больше символов, чем обычное SMS, и не требует ручного разделения на части.";

$smpp->sendSMS($from, $to, '', [
    'data_coding' => SMPP::DATA_CODING_UCS2,
    'message_payload' => $message,
]);

$smpp->close();

These examples demonstrate different ways to use Exolve to send SMS and create newsletters. They cover aspects such as sending simple and multipart messages via SMPP, creating cascading mailings via API, and using payload to send long messages.

Sending SMS when creating an application on the website

A fairly common case is to send an SMS to the client and manager when a new request is received from the site. Let's look at the implementation using the Chronoforms component as an example.

This is a powerful web form builder for Joomla, which can also create surveys, questionnaires with multi-step filling, conditional logic, and so on.

Let's say we have a simple callback order form with the following fields:

To set up SMS sending after filling out the form:

1. In the admin panel, go to “Components” -> Chronoforms -> “Form Management”.

2. Open the call back form.

3. In the “Events” tab, add a new event “After sending”.

4. Select “Send SMS” as the action.

5. In the “Phone number” field, indicate {phone} – so substitute the number from the “Phone” field of the form.

6. In the “Message” field write the SMS text, for example:

Hello {name}! Your request for a call back has been accepted. We will call you back {call_time}. Thanks for reaching out!

7. Fill in the remaining SMS settings as necessary.

8. Save the event and test sending.

To send an SMS to the manager about a new application, you need to add another “After sending” event, but already indicate the manager’s number in the phone number field.

This setting is relevant not only for feedback forms, but also for orders in an online store, booking services, and registering for an event.

Additional event triggers for SMS

In addition to filling out web forms, there are other events on the site, upon the occurrence of which it would be appropriate to send an SMS.

Let us give some typical examples.

Adding an item to your cart

Let us have an online electronics store on Joomla + Virtuemart. To send SMS when adding an item to your cart:

1. Install the Joomla Plugin SMS Notification plugin

2. In its settings, select the SMS gateway we are interested in

3. Specify the OnCartAdd event

4. In the SMS template we write:

{product_name} has been added to your cart. Price {product_price}. Continue shopping: {url}

5. Save the plugin and test

In this way, you can encourage users to complete their purchases.

Unpaid invoice reminder

Let's imagine that the site issues invoices to customers through the Joomla Invoices component. If the client does not pay the invoice within 3 days, it makes sense to send him an SMS reminder.

1. In the administrative panel, go to components, select Joomla Invoices.

2. Create a new invoice template.

3. In the template editor, add the code for sending SMS:

$dueDate = $invoice->due_date;
$threeDaysAfter = date('Y-m-d', strtotime($dueDate . '+3 days'));
$today = date('Y-m-d');

if ($today >= $threeDaysAfter && $invoice->status="Unpaid") {
  // отправляем SMS
  $phoneNumber = $invoice->phone;
  $message = "Здравствуйте! Напоминаем, что ваш счет №{$invoice->number} на сумму {$invoice->total} просрочен. Пожалуйста, оплатите его в течение 2 дней. Спасибо!";
  sendSMS($phoneNumber, $message);
}

function sendSMS($to, $message) {
  // реализация отправки SMS 
}

4. Save the invoice template

The code will check the invoice date, and if more than 3 days have passed and the invoice has not yet been paid, it will send an SMS reminder to the client.

Expiration of subscription on the site

There are often cases when access to site materials or services is provided through a paid subscription. Notifying the client in advance about the imminent end of the subscription will be the right decision.

Let's say subscriptions on the site are implemented through the Akeeba Subscriptions component.

1. Find the file /plugins/akeebasubs/plugins/smsreminder.php

2. It already has an onSubscriptionExpiring method to handle expiring subscriptions

3. Let's modify this method to send SMS:

public function onSubscriptionExpiring($subscription)
{
    if (!$subscription->enabled)
    {
        return;
    }

    $params = $subscription->getParams();
    $daysBeforeExpiration = $params->get('days_before', 0);
    if ($daysBeforeExpiration <= 0)
    {
        return;
    }

    $user = $subscription->getUser();
    $expirationDate = new DateTime($subscription->getExpirationDate());
    $today = new DateTime();
    $today->setTime(0, 0, 0);

    $interval = $today->diff($expirationDate);
    if ($interval->days !== $daysBeforeExpiration)
    {
        return;
    }
    
    $message = "Здравствуйте, {$user->name}! Подписка на наш сервис истекает через {$daysBeforeExpiration} дней - {$expirationDate->format('d.m.Y')}. Продлите подписку на сайте, чтобы не потерять доступ к материалам!";
    sendSMS($user->mobilePhone, $message);
}

Here we check the difference between today's date and the expiration date of the subscription, and if it is equal to the specified number of days in the settings, we send an SMS to the user with a reminder to renew the subscription.

You can do the same with any other events on the site that require a reaction – changing the status of an order, publishing new content, user activity, etc.

When used correctly, SMS notifications can bring significant benefits to a business and increase customer satisfaction.

Conclusion

Integration Exsolve and other services into your Joomla system opens up new opportunities for communication with clients. Using the SMPP protocol or API, you can create powerful alerts that complement your email campaigns.

Remember the importance of complying with technical requirements and optimizing your mailings. Regularly analyze the effectiveness of your SMS campaigns, experiment with different approaches and always take into account customer preferences.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *