Custom subject for form email notifications

answered
#1

I followed instructions to add a subject field to my netlify forms, to provide a custom subject line in email notifications.

This all works fine for a static string.

However, I’d like to insert the form user’s name (from a form input value) into the subject line.

I’m thinking I’ll have to write some javascript to make this work- but before I do, thought I’d ask if anyone has suggestions?

Is there some variable syntax I can use so that on the netlify side they can inject a value into the subject line string?

#2

There is no built-in feature at Netlify to affect the subject, beyond the static string that you found. So indeed your supposition that you’d need to do some “magic” client-side to transform that string before submitting is true! I don’t have any handy code to show this so maybe if you come up with some, you could share it here for future folks on the same adventure?

#3

+1 vote for a feature that server-side will sub a string variable with an input value, so that something like below, would yield a subject line with the submitter’s email address (or any other input value on the form).

<form .... ..../form>

Email clients like gmail, show messages with the same subject as part of an ongoing conversation, grouping them together. A very easy way to lose inbound leads in inbox clutter. Learned this the hard way with some clients :-). Here’s two test messages, showed as one line in gmail. Easy to miss:

image

I will come back and share any client-side JS I come up with that solves the issue, however. My first thought is that it might be tricky when a user is doing multiple edits and validation cycles prior to submit…

#4

Oops, I can see my code example wasn’t escaped properly… this was it:

<form...
<input type="email" name="email>
<input type="text" name="subject" value="{{email}} has sent a message from yourwebsite.com" class="hidden">
.../form>