Send email after custom form submit

Hi,

In Xperience by Kentico, is it possible to send a confirmation email when a contact signs up to a newsletter by using a custom form without going through the form builder form submission (i.e., our own UI with our own backend code for submiting), by using the form builder's autoresponder automation feature in the backend ?

The goal is only to send a confirmation email and not an opt-in.

Otherwise, maybe I see two ways to do it:

1- Use an email template and handle all the sending manually.

2- Use automation to send an email with a custom activity that a user has just subscribed to.

Is there another solution, or which one do you think is the best?

Thank you


Environment

  • Xperience by Kentico version: 31.0.0

  • .NET version:10

  • Execution environment: Private cloud (Azure/AWS/Virtual machine)

Tags:
Community members Kentico Kentico MVP Email channels
0

Answers

Automations are not currently supported at the API level, but we plan to enable custom automation triggers and steps in the future.

Note that skipping the double opt-in flow for recipient lists opens you up to spam and even malicious sign ups. Though, this might not apply if it's only available behind authenticated experiences (e.g. membership).

  1. The Kentico Community Portal source code has an example of how you can send email channel managed emails via custom form submissions. Although some of the APIs are not officially supported (they could experience breaking changes), I have used them for almost 2 years to drive membership experiences here.

    This option would still require you to programmatically add the visitor to the recipient list - it's more work but offers more extensibility.
  2. You could also use global events to respond to the form submission and programmatically add the visitor to the recipient list. The autoresponder email would then be a simple "thank you" email instead of the double opt-in.

Take a look at our Contacts Importer "Lab" integration to see which APIs you can use to programmatically add contacts to recipient lists.

0

Thank you for your response

For your first point I have already seen this sample but I don't want to use Api that are not fully supported/documented. It's risky for future resfresh/update.

For the second point, I must use the XbK form builder to have the autoresponder ? With my custom razor form, I can set the email into the recipient list programmatically with no problem. Then I must send the welcome email programmatically with the emailService or with the autoresponder (I dont understand what you're meaning, is it again with the form builder?)

Thanks again

0

I must use the XbK form builder to have the autoresponder ?

Yes, the Form engine, exposed to marketers through the Form Builder, is what enables a form submission to trigger an auto-responder email. There is a middle ground which lets you set "Custom" for the autoresponder option of a form and that approach is covered in the documentation.

If you don't use form autoresponders or automations you will need to send an email programmatically.

You can send emails programmatically without using emails designed in the Email Builder by using IEmailService directly. This only uses supported, public APIs.

  var emailMessage = new EmailMessage
  {
      From = $"\"Sender name" <[email protected]>",
      Recipients = "[email protected]",
      Subject = "Thanks for submitting the form",
      Body = "<p>This is a confirmation email.</p>",
      PlainTextBody = "...",
      MailoutGuid = Guid.NewGuid()
  };

  await emailService.SendEmail(emailMessage);

You lose the ability for the marketer to manage the design of the email, but you could store the content in a reusable content item in the Content hub and have marketers edit it there.

0

To response this discussion, you have to login first.