1

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:bmxracer3@web.de">
      </form>
    </div>
MrJoky
  • 63
  • 6

2 Answers2

1

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

Kaper365
  • 355
  • 3
  • 14
1

Works as designed.

You are using a mailto: link. This runs on the client side, and hence opens whatever the user has installed to handle email. Could be a mail client or gmail in the browser.

If you want to do this on the server, you need to make a call to your server, e.g., POST to /sendEmail and pass the name and message. Then you can do whatever you want to do on the server: store the message in a database, send an email, and so on.

Robert
  • 7,394
  • 40
  • 45
  • 64