Create Invite API 未发送电子邮件

Hi,

I’ve been sending invites using the api (Discourse API Docs). When I send it on postman, I am getting the invite email. But when I implement it on laravel I’m not getting the email.

Here is the response when the api from laravel. I noticed that the emailed field is false.
image

Postman response the emailed field is true.

Any advice? Thanks.

someone else also reported this,

check this topic

yes this was a different error which was already resolved. the issue now is we’re not getting emails but using the api is successful.

i’m not sure if we need to enable anything? coz when i call the api on postman i get the email but on the laravel app we’ve created we’re not getting the emails.

@yburhaniel

这是一个老话题了,但我遇到了类似的问题。API 请求 invite.json 会生成邀请链接,但不会发送电子邮件。而如果 API 密钥绑定的同一用户从 UI 邀请用户,则电子邮件会正常发送。

你当时是怎么解决这个问题的?

你设置了 send_email 吗?

我正在使用如下的 Python 代码:

invitation = {
          "email": u.mail,
          "group_ids": valid_group_ids(u.groups),
          "send_email": True,
}

site.invites.post(data=invitation)

可以给我们看看你正在使用的代码吗?

您好 @thoka

感谢您的回复。真的这么简单吗?那将是个好消息!

对于这个问题,我正在使用 Zapier,但使用的是我按照这份API 文档创建的一个对象。也许这不是正确的文档,或者我遗漏了其他东西。

我尝试了许多不同的参数,但最新的参数是:

{
"email": "email@email.com",
"skip_email": false,
"custom_message": "Welcome to the forum",
}

我也尝试了以下参数。但不幸的是,这并没有导致邀请被发送:

{
"email": "email@email.com",
"skip_email": false,
"send_email": true,
"custom_message": "Welcome to the forum",
}

但也许我在这里设置的属性仍然是错误的。

我总是使用 Reverse engineer the Discourse API 来使用与 UI 相同的参数。

很好,谢谢你提醒我。我想这是因为在 Discourse 上有更长的使用经验吧。 :slight_smile: 无论如何,你这么说了之后,完全说得通了。

我来试试看,之后再告诉你结果!

@thoka

不幸的是,问题仍然存在,状态码为 OK 200,但只生成了邀请链接。

UI 中的 API 仅额外设置了显式的 expires_atmax_redemptions_allowed 属性。

顺便说一句,我通过集成使用的是 system 用户,这会是个问题吗?话虽如此,我认为我也使用了一个实际的“人类”用户进行了测试。

如果您通过用户界面创建邀请,一切是否都按预期工作?

@thoka

是的,这就是神秘之处,通过 UI,一切都能正常工作,没有问题。

不过,我注意到的是,即使我从 system 用户的个人资料/邀请部分发送邀请,邀请邮件中仍然显示是我(我的用户)发送的邀请。

我建议为您的用户名尝试使用管理员 API 密钥。
通过 API,您应该能够获得与通过 UI 相同的行为。