htmlformsemailhyperlinkhref

Contact Form Submit Button link to Email


I'm completely new to this whole HTML+CSS coding. I wanted to make an easy contact form, that sends the filled form directly to my E-Mail address. By now it just throws me to my mailing program. This is the Code.

Thanks for helping!

    <div class="form">
        <form method="post" action="mailto:bmxracer3@web.de">
            <label for="fname">Vorname</label>
            <input type="text" id="fname" name="firstname" placeholder="Vorname">
            <label for="lname">Nachname</label>
            <input type="text" id="lname" name="lastname" placeholder="Nachname">
            <label for="country">E-mail</label>
            <input type="text" id="email" name="email" placeholder="Ihre E-Mail">
            <label for="subject">Nachricht</label>
            <textarea id="subject" name="Nachricht" placeholder="Ihre Nachricht" style="height:170px"></textarea>
            <input type="submit" value="Absenden" formaction="mailto:example@mail">
      </form>
    </div>


Solution

  • Sadly (vanilla) HTML+CSS doesn't provide possibility to send emails. Such an action can be achieved with PHP. HTML is just a markup language (it tells your browser where various elements are located), whereas CSS is styling language (it tells the browser how do the HTML-defined elements look like).

    Your code opens your default e-mail client, because that's what mailto action does.

    Maybe this answer using PHP can be helpful for you in creating your form: https://stackoverflow.com/a/18382062/12631978