在本地测试Mailgun传入的电子邮件

问题描述 投票:0回答:1

我正在实现从Mailgun获取传入电子邮件的功能。我创造了行动:

[Route("incoming-email/notify")]
[HttpPost]
public async Task<IActionResult> NotifyIncomingEmail([FromForm] CreateIncomingEmailCmd cmd)
{ ... }

并希望在本地调试它(发送到localhost)以检查params是否正确映射。

因此,例如,如果我通过Postman发送x-www-form-urlencoded param body-html然后它没有映射到我的属性BodyHtmlCreateIncomingEmailCmd类和[JsonProperty("body-html")]没有帮助。

我怎样才能做到这一点?

c# .net .net-core asp.net-core-webapi mailgun
1个回答
0
投票

您可以尝试使用ModelBinder属性来指定属性的名称,如下所示:

public class CreateIncomingEmailCmd
{
    [ModelBinder(Name = "body-plain")]
    public string BodyPlain { get; set; }

    [ModelBinder(Name = "body-html")]
    public string BodyHtml { get; set; }
}
© www.soinside.com 2019 - 2024. All rights reserved.