Send PM to an email adress from a plugin

I’m building a plugin and I need to send something to a user’s email.
I use

 creator =, {
        target_recipients: "",
        archetype: Archetype.private_message,
        subtype: TopicSubtype.system_message,
        title: "Hello test subject",
        raw: "This is the message. Does it work ?"

test_user is admin

But every time I try to send using this, I get the error :
Topic is empty

Any idea ?

According to the specs, that should take a group name or a username:


Hello Robert,

That’s weird because on the front end, Discourse uses a payload like this and it is working (tested with my private email) :

raw: Again a message content here.
title: Hello there general kenoby
archetype: private_message

I found it weird that we are expecting a group name on the backend :confused:

1 Like

TL;DR use target_emails not target_recipients

Note that target_recipients is a parameter to PostsController, not an argument for PostCreator.
That controller figures out if the recipients are users, groups or email addresses and then eventually passes it as target_emails to NewPostsManager and it ends up in TopicCreator.


Thank you ! That was it :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.