Mail sees 2 from addresses when name enabled

I have the following script:
const sendForm = async (form) => {
let sendRequest = new Request('https://api.mailchannels.net/tx/v1/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
personalizations: [
{
to: [{ email: 'web-contactus@sbsoftware.ca' }],
},
],
from: {
email: form.email,
name: `${form.lname}, ${form.fname}`, // Causes an ERROR (multiple from addresses)
},
subject: `Contact Us - ${form.lname}, ${form.fname} (${form.subject})`,
content: [
{
type: 'text/html',
value: form.message,
},
],
}),
});

const response = await fetch(sendRequest);
const responseText = await response.text();

return responseText;
};
const sendForm = async (form) => {
let sendRequest = new Request('https://api.mailchannels.net/tx/v1/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
personalizations: [
{
to: [{ email: 'web-contactus@sbsoftware.ca' }],
},
],
from: {
email: form.email,
name: `${form.lname}, ${form.fname}`, // Causes an ERROR (multiple from addresses)
},
subject: `Contact Us - ${form.lname}, ${form.fname} (${form.subject})`,
content: [
{
type: 'text/html',
value: form.message,
},
],
}),
});

const response = await fetch(sendRequest);
const responseText = await response.text();

return responseText;
};
And I don't really understand why... after all the from: field is an object, not an array... The form input is good, there are no issues there
1 Reply
boywithkeyboard
boywithkeyboard17mo ago
i don't quite understand your issue here? can you give me more detail?