Take the form information and send it to e-mail

Asked

Viewed 75 times

0

I have a form that I will have to take the information typed and send to my email via java script or jquery but I do not know how to do it so far only Read my form follows the code of my form:

.corpo-1 ul li {

  display: block;

  margin: 10px;

  text-align: center;

}

.corpo-1 ul {

  margin-top: 10%;

}

.contato-barra {

  width: 10%;

  height: 2px;

  background-color: #000;

  border: none;

}

input[type="text"] {

  border: 1px solid #000;

  border-radius: 5px;

  width: 300px;

  height: 25px;

  background-color: transparent;

  font-family: Gabriola;

  font-size: 1.2em;

  outline: none;

}

.teste1 {

  margin-left: 65%;

  background-color: aquamarine;

  width: 100px;

  height: 50px;

  color: #000;

  display: none;

}

select {

  border: 1px solid #000;

  border-radius: 5px;

  width: 300px;

  height: 40px;

  background-color: transparent;

  font-family: Gabriola;

  font-size: 1.2em;

  outline: none;

}

textarea {

  border: 1px solid #000;

  border-radius: 5px;

  width: 300px;

  height: 100px;

  background-color: transparent;

  font-family: Gabriola;

  font-size: 1.2em;

  outline: none;

}

#enviar {

  background-color: #000;

  width: 300px;

  height: 50px;

  border: none;

  border-radius: 5px;

  color: #fff;

  font-family: Gabriola;

  font-size: 1.3em;

  text-align: center;

  cursor: pointer;

  outline: none;

}

#enviar:hover {

  background-color: #333;

}

#bg-fundo {

  position: absolute;

  z-index: -1;

  opacity: 0.25;

  left: 0;

  right: 0;

  margin: auto;

  margin-top: -18%;

  /*width: 50%;*/

  transform: scale(1);

}
<section class="corpo-1">
  <div id="formulario">
    <form method="post" action="">
      <ul>
        <li>
          <input type="text" id="nome" placeholder="  Digite seu nome" required name=nome>
        </li>
        <li>
          <input type="text" placeholder="  Digite seu Email" required name=email>
        </li>
        <li>
          <input type="text" placeholder="  Digite seu Nickname" required name=nickname>
        </li>
        <li>
          <select>
            <option value="the-elder" selected>--- Selecione um jogo ---</option>
            <option value="the-elder">The Elder Scrols Online</option>
            <option value="archage">ArcheAge</option>
            <option value="worlofwarcraft">World of War Craft</option>
            <option value="forsaken">Forsaken World</option>
            <option value="leagueoflegends">League of Legends</option>
            <option value="dota">Dota 2</option>
            <option value="smite">Smite</option>
            <option value="warface">Warface</option>
            <option value="cs">CS-GO</option>
            <option value="bf">Battle Field</option>
            <option value="cod">Call of Dutty</option>
          </select>
        </li>
        <li>
          <textarea placeholder="  Mensagem" required name=mensagem></textarea>
        </li>
        <li>
          <input type=submit value="Enviar" id="enviar" />
        </li>
      </ul>
    </form>
  </div>
</section>

Note: My email will be sent to mine in case [email protected]

2 answers

3

Unable to send email using Javascript only. You should use a server language for this, for example PHP.

But you can use the command window.open('mailto:[email protected]'); to open the standard email program and send the email.

You can also pass parameters in the command: window.open('mailto:[email protected]?subject=assunto&body=corpo');

Example in PHP:

<?php
$para       = '[email protected]';
$assunto    = 'Algum Assunto';
$mensagem   = 'Olá';
$cabecalhos = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($para, $assunto, $mensagem, $cabecalhos);
?>
  • there is some documentation of this or somewhere with the code ready or with more information I do not know these things

  • 3

    @Kirito http://lmgtfy.com/? q=mailto

  • 1

    @Kirito On how to email with PHP you can see the official manual: http://php.net/manual/en/function.mail.php

  • Friends that is not your concern but I am very bad with this language would be possible to pose a prototype of code so I can understand better if it is not asking too much

  • 1

    @Kirito I updated the answer with a PHP example.

  • @Earendul friend then omeu file contact this with the . html extension I will have to change tbm and put . php??? and as for your code I place it in the body of my site or in the head of my archive

  • @Earendul friend opened a new topic with my php code gives a look at : http://answall.com/questions/66243/formul%C3%A1rio-n%C3%A3o-send-as-informs%C3%A7%C3%B5es-to-e-mail

Show 2 more comments

1

You really have to use a server language to send your email. PHP is very good at this, read here a very complete article on how to do this.

There is also Phpmailer, here is another article explaining about it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.