Trying out the new MailChannel integration on Pages and I seem to be able to send an email from a form on my site, but when I receive the email it has no body content at all. I am not specifying the ‘content’ array for html/text versions so it should be using the default provided by the plugin as far as I can tell.
Here is the middleware code stored in /functions/_middleware.js
(redacted for privacy)
import mailchannelsPlugin from '@cloudflare/pages-plugin-mailchannels'
export const onRequest = mailchannelsPlugin({
from: { name: '#######', email: 'no-reply@#########' },
personalizations: [
{
to: [{ name: '#########', email: '#############' }],
},
],
respondWith: () =>
new Response(null, {
status: 302,
headers: { Location: '/enquiries/thank-you' },
}),
subject: '######### Website Enquiry',
})
form (class attributes removed for brevity)
<form data-static-form-name="contact">
<div>
<div>
<label for="first-name">First name</label>
<input type="text" name="first-name" id="first-name" autocomplete="given-name"/>
</div>
<div>
<label for="last-name">Last name</label>
<input type="text" name="last-name" id="last-name" autocomplete="family-name"/>
</div>
<div>
<label for="email-address">Email address</label>
<input type="text" name="email-address" id="email-address" autocomplete="email"/>
</div>
<div>
<label for="phone">Phone</label>
<input type="text" name="phone" id="phone" autocomplete="phone"/>
</div>
<div>
<label for="message">Message</label>
<textarea id="message" name="message" rows="4"/>
</div>
</div>
<div>
<button type="submit">Send Enquiry</button>
</div>
</form>
Any help would be appreciated.