3 Replies Latest reply: Jun 12, 2014 9:26 AM by elbuenrobin RSS

    help with a contact form script

    elbuenrobin

      I have this contact form but it doesn't send the email

       

      this is the page www.vonhaucke.mx

       

      and the script for contacto.php is:

      <!DOCTYPE html>

      <html>

      <head>

      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

      <title>.:vonhaucke:.</title>

      <link href="contacto.css" rel="stylesheet" type="text/css" media="screen" />

       

       

      </head>

       

       

      <body>

      <table align="center" border="0" cellspacing="0" cellpadding="0">

        <tr>

          <td width="372"> </td>

          <td width="278" class="margen"><div id="logo" class="logo"><img src="img/logovonhaucke.png" width="228" height="71" alt="Vonhaucke" title="Vonhaucke"></div></td>

        </tr>

        <tr>

          <td style="border-bottom:#CCC solid 1px; border-top:#CCC solid 1px;"><h1>Contacto</h1></td>

          <td style="border-bottom:#CCC solid 1px; border-left:#CCC solid 1px; border-top:#CCC solid 1px;"> </td>

        </tr>

        <tr>

          <td valign="top" align="right">

        <div id="contact" align="right">   

        <form action="enviar.php" method="post">

        <label for="name">Nombre:</label>

        <input type="text" name="nombre" /><br />

                 

        <label for="name">Apellido:</label>

        <input type="text" name="apellido" /><br />

                 

        <label for="name">Empresa:</label>

        <input type="text" name="empresa" /><br />              

       

        <label for="email">Email:</label>

        <input type="email" name="mail" /><br />

                 

        <label for="name">Página web:</label>

        <input type="text" name="web" /><br />

                 

        <label for="name">Teléfono:</label>

        <input type="text" name="telefono" /><br />                       

       

        <label for="message">Comentarios:</label>

        <textarea name="comentarios"></textarea><br />

       

        <input type="submit" value="Enviar" />

        </form>

          </div>

          </td>

          <td class="margen">

              <div id="direccion">

                  <strong>Sala de Exhibición y Oficinas</strong><br />Paseo de la Reforma 284 PH<br />

                  Col. Juárez Del Cuauhtémoc<br />06600 México DF<br />T :: 5999 9200<br />

                 www.vonhaucke.mx<br />       

                  <strong>Aguascalientes</strong><br />T :: 014499145150.<br />E-mail :: vonhauckebajio_ags@yahoo.com.mx<br />

                  <strong>Bajio</strong><br />T :: 014422150577.<br />E-mail :: vonhauckebajio@gmail.com<br />

                  <strong>Cancún</strong><br />T :: 019988920272.<br />E-mail :: xochitl@zentarte.com<br />

                  <strong>Hidalgo</strong><br />T :: 0445539243356.<br />E-mail :: xariel_mexico@hotmail.com<br />

                  <strong>Puebla</strong><br />T :: 012224661905.<br />E-mail :: eduardogarciacasas@yahoo.com.mx<br />

                  <strong>Toluca</strong><br />T :: 017222714990.<br />E-mail :: avantek1@prodigy.net.mx<br />

                  <strong>Nueva York</strong><br />(800) 7113572<br />Sherry Mitchel Inc. Vonhaucke<br />P.O. Box 3035<br />Sea Bright, N,J. 07760

              </div> <br />

          </td>

        </tr>

        <tr>

          <td colspan="2" align="center">

          <div id="ubicacion">Paseo de la Reforma 284 PH, Col. Juárez, Del. Cuauhtémoc, C.P. 06600, México D.F. T.(55) 5999 9200, e-mail. info@vonhaucke.mx</div>

          </td>

        </tr>

      </table>

      </body>

      </html>

       

       

      the script for enviar.php is

      <?php

      $nombre = $_POST['nombre'];

      $apellido=$_POST['apellido'];

      $empresa = $_POST['empresa'];

      $mail = $_POST['mail'];

      $web = $_POST['web'];

      $telefono = $_POST['telefono'];

      $comentarios = $_POST['comentarios'];

       

       

      $header = 'From: ' . $mail . " \r\n";

      $header .= "X-Mailer: PHP/" . phpversion() . " \r\n";

      $header .= "Mime-Version: 1.0 \r\n";

      $header .= "Content-Type: text/plain";

       

       

      $mensaje = "Este mensaje fue enviado por " . $nombre ." ". $apellido. ", de la empresa " . $empresa . ", Sitio web: " . $web . " \r\n";

      $mensaje .= "Su e-mail es: " . $mail . " \r\n";

      $mensaje .= "Mensaje: " . $_POST['comentarios'] . " \r\n";

      $mensaje .= "Enviado el " . date('d/m/Y', time());

       

       

      $para = 'info@vonhaucke.mx';

      $asunto = 'Comentarios desde sitio web: vonhaucke';

       

       

      mail($para, $asunto, utf8_decode($mensaje), $header);

       

       

      //echo 'Mensaje enviado correctamente';

      ?>

      <!DOCTYPE html>

      <html>

      <head>

      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

      <title>.:vonhaucke:.</title>

      <link href="contacto.css" rel="stylesheet" type="text/css" media="screen" />

       

       

      </head>

       

       

      <body>

      <table align="center" border="0" cellspacing="0" cellpadding="0">

        <tr>

          <td width="372"> </td>

          <td width="278" class="margen"><div id="logo" class="logo"><img src="img/logovonhaucke.png" width="228" height="71" alt="Vonhaucke" title="Vonhaucke"></div></td>

        </tr>

        <tr>

          <td style="border-bottom:#CCC solid 1px; border-top:#CCC solid 1px;"><h1>Contacto</h1></td>

          <td style="border-bottom:#CCC solid 1px; border-left:#CCC solid 1px; border-top:#CCC solid 1px;"> </td>

        </tr>

        <tr>

          <td valign="top" align="right">

        <div id="contact" align="right">   

        <form action="#" method="post">

        <p align="center">Mensaje enviado correctamente</p>

              <input type="button" onClick="parent.$.modal().close()" value="Cerrar">

        </form>

          </div>

          </td>

          <td class="margen">

              <div id="direccion">

                  <strong>Aguascalientes</strong><br />T :: 014499145150.<br />E-mail :: vonhauckebajio_ags@yahoo.com.mx<br />

                  <strong>Bajio</strong><br />T :: 014422150577.<br />E-mail :: vonhauckebajio@gmail.com<br />

                  <strong>Cancún</strong><br />T :: 019988920272.<br />E-mail :: xochitl@zentarte.com<br />

                  <strong>Hidalgo</strong><br />T :: 0445539243356.<br />E-mail :: xariel_mexico@hotmail.com<br />

                  <strong>Puebla</strong><br />T :: 012224661905.<br />E-mail :: eduardogarciacasas@yahoo.com.mx<br />

                  <strong>Toluca</strong><br />T :: 017222714990.<br />E-mail :: avantek1@prodigy.net.mx<br />

                  <strong>Nueva York</strong><br />(800) 7113572<br />Sherry Mitchel Inc. Vonhaucke<br />P.O. Box 3035<br />Sea Bright, N,J. 07760

              </div> <br />

          </td>

        </tr>

        <tr>

          <td colspan="2" align="center">

          <div id="ubicacion">Paseo de la Reforma 284 PH, Col. Juárez, Del. Cuauhtémoc, C.P. 06600, México D.F. T.(55) 5999 9200, e-mail. info@vonhaucke.mx</div>

          </td>

        </tr>

      </table>

      </body>

      </html>

       

      I don't know why is not sending the email to info@vonhaucke.mx

        • 1. Re: help with a contact form script
          osgood_ CommunityMVP

          Your script works ok when I test it out - the information is sent to the specified email address - although I don't know what the below code has to do with it all? (I've blanked the email addresses to avoid spam)

           

           

           

           

          <!DOCTYPE html>

          <html>

          <head>

          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

          <title>.:vonhaucke:.</title>

          <link href="contacto.css" rel="stylesheet" type="text/css" media="screen" />

           

           

          </head>

           

           

          <body>

          <table align="center" border="0" cellspacing="0" cellpadding="0">

            <tr>

              <td width="372"> </td>

              <td width="278" class="margen"><div id="logo" class="logo"><img src="img/logovonhaucke.png" width="228" height="71" alt="Vonhaucke" title="Vonhaucke"></div></td>

            </tr>

            <tr>

              <td style="border-bottom:#CCC solid 1px; border-top:#CCC solid 1px;"><h1>Contacto</h1></td>

              <td style="border-bottom:#CCC solid 1px; border-left:#CCC solid 1px; border-top:#CCC solid 1px;"> </td>

            </tr>

            <tr>

              <td valign="top" align="right">

            <div id="contact" align="right">   

            <form action="#" method="post">

            <p align="center">Mensaje enviado correctamente</p>

                  <input type="button" onClick="parent.$.modal().close()" value="Cerrar">

            </form>

              </div>

              </td>

              <td class="margen">

                  <div id="direccion">

                      <strong>Aguascalientes</strong><br />T :: 014499145150.<br />E-mail :: xxxxxxxxx@xxxxxxxx<br />

                      <strong>Bajio</strong><br />T :: 014422150577.<br />E-mail :: xxxxxxxxx@xxxxxxxx<br />

                      <strong>Cancún</strong><br />T :: 019988920272.<br />E-mail :: xxxxxxxxx@xxxxxxxx<br />

                      <strong>Hidalgo</strong><br />T :: 0445539243356.<br />E-mail :: xxxxxxxxx@xxxxxxxx<br />

                      <strong>Puebla</strong><br />T :: 012224661905.<br />E-mail :: xxxxxxxxx@xxxxxxxx<br />

                      <strong>Toluca</strong><br />T :: 017222714990.<br />E-mail :: xxxxxxxxx@xxxxxxxx<br />

                      <strong>Nueva York</strong><br />(800) 7113572<br />Sherry Mitchel Inc. Vonhaucke<br />P.O. Box 3035<br />Sea Bright, N,J. 07760

                  </div> <br />

              </td>

            </tr>

            <tr>

              <td colspan="2" align="center">

              <div id="ubicacion">Paseo de la Reforma 284 PH, Col. Juárez, Del. Cuauhtémoc, C.P. 06600, México D.F. T.(55) 5999 9200, e-mail. xxxxx@xxxxxx</div>

              </td>

            </tr>

          </table>

          </body>

          </html>

          • 2. Re: help with a contact form script
            David_Powers CommunityMVP

            The reason the mail is not being sent could be that your hosting company requires the fifth argument to mail() to verify the origin of the email.

             

            Another reason could be that you're setting the From header to a value drawn from the form. This is not only incorrect, it's extremely insecure. The From header indicates where the email originated, which is your website. It's not the person who fills in the form. If you want to add the sender's email to the headers, you should use the Reply-To header. What's more, you need to validate the email before inserting it into the headers. Otherwise, you risk turning your site into a spam relay.

             

            For a full explanation of both these issues, see the following tutorial on my site: Adding a reply address in PHP mail().

            • 3. Re: help with a contact form script
              elbuenrobin Community Member

              Osgood, thanks for the answer that script was part or the hole page, don't mind it.