Did you ever think about it? Someone types the message, clicks on send and gets the error message like "Something went wrong. Sorry...". Ok, what now? How TF can I send you a message?
Contact form is often the only way you can communicate with someone. People just don't like to expose their email addresses just like that. But having a contact form means that it might fail at some point. Your SMTP server could be down or your application could just stop working. It happened so many times.
So what can you do?
Well, instead of showing seamless error message and informing users that your application broke, you can offer them an alternative. Instead of showing a message "An error occurred. Your email cannot be sent", you can show "An error occurred and your email cannot be sent. However, you can still contact me on firstname.lastname@example.org". Much better, isn't it?
Better? Yes, but not good enough
What if someone just typed several paragraphs? There is a small chance that he/she will type it again unless it is something seriously important. There is very simple trick to avoid this problem. Literally, copy the text user typed and paste it into the email link.
If you have these two input fields (beside other) in your contact form:
<input type="text" id="subject">
<input type="text" id="message">
var subject = document.getElementById("subject").value;
var msg = document.getElementById("message").value;
var link = document.getElementById("emailme");
link.href="mailto:email@example.com?subject=" + subject + "&body=" + msg;
And your error message could look like this:
<div id="errorMessage">Error Occured. Please contact me on <a id="emailme" href="firstname.lastname@example.org">email@example.com</a></div>
Pretty simple, but do you know any other way to do this? How would you solve this problem?