How do I add the Reply To email header in Mailjet API? Or other headers?
Google search reveals the property ReplyEmail
but that is only for Newsletter.Resource
and not for Send.Resource
.
How do I add the Reply To email header in Mailjet API? Or other headers?
Google search reveals the property ReplyEmail
but that is only for Newsletter.Resource
and not for Send.Resource
.
Using MailJet V3 API:
MailjetClient client = new MailjetClient("MJ_APIKEY_PUBLIC", "MJ_APIKEY_PRIVATE");
MailjetRequest request = new MailjetRequest
{
Resource = Send.Resource,
}
.Property(Send.FromEmail, "[email protected]")
.Property(Send.FromName, "Mailjet Pilot")
.Property(Send.Subject, "Your email flight plan!")
.Property(Send.TextPart, "Dear passenger, welcome to Mailjet!")
.Property(Send.HtmlPart, "<h3>Dear passenger, welcome to Mailjet!</h3>")
.Property(Send.Recipients, new JArray {
new JObject {
{"Email", "[email protected]"}
}
})
.Property(Send.Headers, new JObject {
{"Reply-To", "[email protected]"}
});
MailjetResponse response = await client.PostAsync(request);
Using the Send.Headers, from this link: https://dev.mailjet.com/guides/#adding-email-headers-v3 And slightly different for V3.1: https://dev.mailjet.com/guides/#send-api-v3-to-v3-1
To save people time: if you are getting 200 success status code but no emails, check your allowed senders list. Also "Bcc" doesn't work with "Recipients", "Bcc" should be used with the "To" field.
Sending email with Reply-to using the MailJet PHP library:
$mj = new \Mailjet\Client('xxxxxxxxxxx','xxxxxxxxxxx',true,['version' => 'v3.1']);
$body = [
'Messages' => [
[
'From' => [
'Email' => "",
'Name' => ""
],
'To' => [
[
'Email' => "",
'Name' => ""
]
],
'Subject' => "",
'TextPart' => "",
'HTMLPart' => "",
'Headers' => [
'Reply-To' => ""
]
]
]
];
$response = $mj->post(Resources::$Email, ['body' => $body]);
$response->success();
© 2022 - 2024 — McMap. All rights reserved.