Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Ok...I'm sure this has been answered somewhere but I can't find it. So thanks in advance to you coding gurus!

So, I have an HTML form with an action referencing formspree. One of the shortcomings of formspree is the inability to send an auto reply email based on input put into the "email" field.

How can I get the form to submit the form to formspree and send an auto reply? Below is my code for the form:

*********************
HTML
<form action="https://formspree.io/xxxxxxxxxx@xxxx.com"  method="POST">   			
<label for="name">Name: <span class="required">*</span></label>
            <input type="text" id="name" Name="Name" value="" placeholder="John Doe" required="required" autofocus />
            <label for="email">Email Address: <span class="required">*</span></label>
            <input type="email" id="email" name="E-mail" value="" placeholder="johndoe@example.com" required="required" />
            <label for="telephone">Contact Number: </label>
            <input type="tel" id="Telephone" name="Telephone" value="" />
            <label for="contact">Preferred Contact Method: </label>
            <select id="contact" name="Preferred Contact Method:">
              <option value="email">Email</option>
              <option value="phone">Phone - During the Day</option>
              <option value="phone">Phone - In the Eveneing</option>
              <option value="phone">Phone - Anytime</option>
            </select>
            <label for="enquiry">Purpose: </label>
            <select id="enquiry" name="Reason:">
              <option value="general">General Info</option>
              <option value="offer">Introductory Offer</option>
              <option value="experienced">Experienced CrossFitter</option>
              <option value="feedback">Your Feedback</option>
            </select>
            <label for="message">Message: <span class="required">*</span></label>
            <textarea id="message" name="Message" placeholder="Your message must be greater than 20 charcters" required data-minlength="20"></textarea>
            <span id="loading"></span>
            <input type="submit" value="SUBMIT"  id="submit-button" />
            <p id="req-field-desc"><span class="required">*</span> indicates a required field</p>
</form> 

**************************

What I have tried:

Research and "onclick' but since the input for the submit isn;t a button I don;t think the onclick works
Posted
Updated 22-Aug-17 19:39pm

1 solution

You can't do this with HTML or JavaScript - or Formspree. If you use a server-side language (i.e. ASP.NET or PHP) as well, you better set the "action" to something on your own server and read the email address from there and send an email there - but as you use formspree, I don't think you use a server-side language.

However, there are alternatives if you don't use a server-side language:

  • Use an email client that supports scripting, write a script that handles incoming email from the form, extracts the email address, and replies. Your computer and client would have to be turned on all the time though, otherwise you wouldn't have instant replies.
  • If you don't want to use a mail client, you can pick a programming language to write some software that communicates with the email server of your email address (look into the IMAP or POP3 protocols) and process the emails like this. This is of course harder than email client scripting, because you also have to deal with the email server communication. And again, you need to have this running 24/7 to guarantee instant replies.
 
Share this answer
 
Comments
wiltim 23-Aug-17 8:54am    
Ok...follow on to your response.

Utilizing, say PHP, can I leverage two actions there?

So for my action use something like 'action="twoactions.php"' and in the PHP script have it submit the form to formspree AND send an auto reply?

Or would it be easier just to stop using formspree all together and utilize a custom script from my form?

The nice thing about formspree is it's easy...I simply tell it where to send the form data and it does it all for me. but if its creating more problems going forward I'd rather make a move now than deal with it later
Thomas Daniels 23-Aug-17 9:22am    
You don't leverage two actions using HTML; You use one action, and let the PHP script do everything it has to do. If you use PHP, you don't even need formspree anymore, because you can just use your own server.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900