MailJet:HTTP POST 状态代码 200 但电子邮件发送被阻止
MailJet: HTTP POST status code 200 but email sending is blocked
我在 "Send a mail" example here 之后使用以下 C# 代码使用模板通过 MailJet 发送电子邮件。该模板有一个变量 {{var:name}}
,它是收件人的姓名。
int templateID = 610379;
MailjetRequest request = new MailjetRequest
{
Resource = Send.Resource,
}
.Property(Send.FromEmail, ConfigurationManager.AppSettings["MailJetFromEmail"].ToString())
.Property(Send.FromName, "Support Team")
.Property(Send.MjTemplateID, templateID)
.Property(Send.MjTemplateLanguage, true)
.Property(Send.Vars, new JArray
{
new JObject
{
{ "name", "Name of the customer"}
}
})
.Property(Send.Recipients, new JArray
{
new JObject
{
{ "Email", "testemailtosend@gmail.com" }
}
});
MailjetResponse response = await client.PostAsync(request);
if (response.IsSuccessStatusCode)
{
// Log success
}
else
{
// Log error
}
虽然 response.IsStatusSuccessCode
等于 true
,但我的电子邮件一直被阻止。 谁能解释一下为什么电子邮件被阻止以及如何解决?
当 subject
不存在时,许多电子邮件服务器将 "block"。
问题是我实际上在电子邮件模板中有多个变量,但只指定了其中一个。 (这让我感到困惑,因为我确实为其他变量设置了默认值,但事实证明,如果所有变量的值都已指定,MailJet 只会发送电子邮件)
这个
.Property(Send.Vars, new JArray
{
new JObject
{
{ "name", "Name of the customer" }
}
})
应该是这个
.Property(Send.Vars, new JArray
{
new JObject
{
{ "name", "Name of the customer" }
{ "org", "Organization of the customer" }
}
})
因为电子邮件模板中的另一个变量是组织。
我在 "Send a mail" example here 之后使用以下 C# 代码使用模板通过 MailJet 发送电子邮件。该模板有一个变量 {{var:name}}
,它是收件人的姓名。
int templateID = 610379;
MailjetRequest request = new MailjetRequest
{
Resource = Send.Resource,
}
.Property(Send.FromEmail, ConfigurationManager.AppSettings["MailJetFromEmail"].ToString())
.Property(Send.FromName, "Support Team")
.Property(Send.MjTemplateID, templateID)
.Property(Send.MjTemplateLanguage, true)
.Property(Send.Vars, new JArray
{
new JObject
{
{ "name", "Name of the customer"}
}
})
.Property(Send.Recipients, new JArray
{
new JObject
{
{ "Email", "testemailtosend@gmail.com" }
}
});
MailjetResponse response = await client.PostAsync(request);
if (response.IsSuccessStatusCode)
{
// Log success
}
else
{
// Log error
}
虽然 response.IsStatusSuccessCode
等于 true
,但我的电子邮件一直被阻止。 谁能解释一下为什么电子邮件被阻止以及如何解决?
当 subject
不存在时,许多电子邮件服务器将 "block"。
问题是我实际上在电子邮件模板中有多个变量,但只指定了其中一个。 (这让我感到困惑,因为我确实为其他变量设置了默认值,但事实证明,如果所有变量的值都已指定,MailJet 只会发送电子邮件)
这个
.Property(Send.Vars, new JArray
{
new JObject
{
{ "name", "Name of the customer" }
}
})
应该是这个
.Property(Send.Vars, new JArray
{
new JObject
{
{ "name", "Name of the customer" }
{ "org", "Organization of the customer" }
}
})
因为电子邮件模板中的另一个变量是组织。