I run a small static site on Cloudflare Pages. Its contact page had a plain HTML form that posted to a Pages Function. This week I checked whether that form actually worked. It did not, and nothing a visitor could see would have told me why.
How the form was built
functions/api/contact.js reads the POST body, validates the email address and the message length, and sends the message through Brevo’s transactional email API. Whatever happens, it answers with a 303 redirect back to the contact page and carries the result in the query string: ?sent=ok , or ?sent=error&why=<reason> . The page reads that and shows a short status line.
The send step starts like this:
if ( ! env . BREVO_API_KEY ) { console . error ( ' contact: BREVO_API_KEY is not set on this Pages project ' ); return back ( url , ' error ' , ' config ' ); }
Enter fullscreen mode
Exit fullscreen mode
That branch is reasonable.…