Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sending transactional email with dynamic data not to subscribers #2204

Closed
meilook7 opened this issue Dec 10, 2024 · 2 comments
Closed

sending transactional email with dynamic data not to subscribers #2204

meilook7 opened this issue Dec 10, 2024 · 2 comments
Labels
question Further information is requested

Comments

@meilook7
Copy link

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!
@meilook7 meilook7 added the question Further information is requested label Dec 10, 2024
@knadh
Copy link
Owner

knadh commented Dec 10, 2024

Hi @meilook7. This is currently a limitation in listmonk. Only an existing subscriber can receive transactional e-mails. There's a pending PR for this #1754 which may be considered for the next version.

@knadh knadh closed this as completed Dec 10, 2024
@meilook7
Copy link
Author

Hi @meilook7. This is currently a limitation in listmonk. Only an existing subscriber can receive transactional e-mails. There's a pending PR for this #1754 which may be considered for the next version.

i succeed to send an email to someone not in my subscribers with that way but not to add a dynamic data its just a HTML string... with that way its not possible?

const result = await mailClient.sendHtmlEmail( " Test Email", "[email protected]", testHtml );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants