Skip to content

sending transactional email with dynamic data not to subscribers #2204

Closed
@meilook7

Description

@meilook7

I hope this message finds you well. I’m reaching out regarding an issue I’m encountering with sending dynamic data emails using Listmonk.
I want to send emails to any email address, passing dynamic data (e.g., name, phone number) directly into the template without using string replacement functions like .replace(). The dynamic data should be injected seamlessly into the template.

This works perfectly for email addresses already subscribed and listed in my subscribers’ database. However, if I attempt to send it to an email address that is not listed, the process fails.

I would appreciate your suggestions on how to fix this issue and enable sending dynamic data emails to any email address, regardless of its subscription status.

this is my function:

```

case "send-aws-email-to-email": {
try {
const listmonkConfig = this.app.get("listmonk");
const baseUrl = baseUrl;

      // Dynamic data for the email
      const dynamicData = {
        name: "testName",
        order_id: "123456",
      };
  
      // Prepare the payload for the transactional email
      const payload = {
        subscriber_email: (data as any).email,
        template_id: 3,
        data: dynamicData,
        content_type: "html",
      };
  
      // Send the transactional email using Listmonk API
      const response = await axios.post(`${baseUrl}/api/tx`, payload, {
        auth: {
          username: listmonkConfig.username,
          password: listmonkConfig.password,
        },
      });
  
      console.log("Transactional email sent successfully:", response.data);
    } catch (error) {
      console.error("Error sending transactional email:", error);
    }
    break;
  }

again now its works only if the email is in the subscribers
Thank you in advance for your time and assistance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions