Jump to content

Recommended Posts

No, I think is not the mail function.

Here is the code.

<?php

  
			 $error    = ''; // error message
                 $name     = ''; // sender's name
                 $email    = ''; // sender's email address
                 $subject  = ''; // subject
                 $message  = ''; // the message itself
			 $telefono = ''; // the sender's phone
			 $pais = ''; // the sender's country
			 $calle = ''; // the sender's adress
			 $ciudad = ''; // the sender's city
               	 $estado = ''; // the sender's state
			 $spamcheck = ''; // Spam check

        


            if(isset($_POST['send']))
            {
                 $name     = $_POST['name'];
                 $email    = $_POST['email'];
                 $subject  = $_POST['subject'];
                 $message  = $_POST['message'];
			 $telefono = $_POST['telefono'];
			 $pais = $_POST['pais'];
			 $calle = $_POST['calle'];
			 $ciudad = $_POST['ciudad'];
			 $estado = $_POST['estado'];
			  

                if(trim($name) == '')
                {
                    $error = '<div class="errormsg">Por favor escriba su nombre!</div>';
                }
            	    else if(trim($email) == '')
                {
                    $error = '<div class="errormsg">Por favor indique Email!</div>';
                }
                else if(!isEmail($email))
                {
                    $error = '<div class="errormsg">Su Email no es válido, por favor intente de nuevo!</div>';
                }
            	else if(trim($calle) == '')
                {
                    $error = '<div class="errormsg">Escriba su dirección!</div>';
                }
			else if(trim($ciudad) == '')
            {
            	$error = '<div class="errormsg">Por favor indique su ciudad!</div>';
            }
			else if(trim($estado) == '')
            {
            	$error = '<div class="errormsg">Por favor indique su estado!</div>';
            }
          	else if(trim($pais) == '')
            {
            	$error = '<div class="errormsg">Por favor indique su país!</div>';
            }
			else if(trim($telefono) == '')
            {
            	$error = '<div class="errormsg">Por favor indique su teléfono!</div>';
            }
			else if(trim($message) == '')
                {
                    $error = '<div class="errormsg">Escriba su mensaje!</div>';
                }
                if($error == '')
                {
                    if(get_magic_quotes_gpc())
                    {
                        $message = stripslashes($message);
                    }

                    // the email will be sent here
                    // make sure to change this to be your e-mail
                   

                    // the email subject
                    // '[Contact Form] :' will appear automatically in the subject.
                    // You can change it as you want

                    $subject = '[Contacto web] : ' . $name;
				$to = "joelbedoy@live.com.mx";
                    // the mail message ( add any additional information if you want )
                    $msg = ("De: $name \r\ne-Mail: $email \r\nDirección: $calle \r\nCiudad: $ciudad \r\nEstado: $estado \r\nPaís: $pais \r\nTeléfono: $telefono\r\n\n" . "Mensaje: \r\n$message");

	sendmail($email, $name, $to, $subject, $msg);	

			function sendmail($email, $name, $to ,$subject, $msg){
	include("class.phpmailer.php");
	include("class.smtp.php");

    $mail = new PHPMailer ();


$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "user@gmail.com";
$mail->Password = "password";

$mail->From = $email;
$mail->FromName = $name;
$mail->Subject = $subject;
$mail->MsgHTML($msg);



$mail->AddAddress($to);


$mail->IsHTML (true);



if(!$mail->Send()) 
	return(1);
else 
	return(0);

}

            ?>
      
      <!-- Message sent! -->
      <div class="contactForm" style="text-align:center;">
        <h5>Mensaje enviado</h5>
        <p>Gracias <b>
          <?=$name;?>
          </b>, le responderemos lo antes posible!</p>
      </div>
      <!--End Message Sent-->
      
      <?php
                }
            }

            if(!isset($_POST['send']) || $error != '')
            {
            ?>
      
      <!--Error Message-->
      <?=$error;?>
      <form style="margin-top:10px;"  method="post" name="contFrm" id="contFrm" action="" accept-charset="utf-8">
        <label class="contactForm" style="margin-left:0px;"><span class="required">*</span> Nombre:</label>
        <input name="name" type="text" class="box" id="name" size="25" value="<?=$name;?>" />
        <label class="contactForm" style="width:50px; margin-left:3px;"><span class="required">*</span> Email: </label>
        <input name="email" type="text" class="box" id="email" size="25" value="<?=$email;?>" />
        <label style="clear:left; width:72px;" class="contactForm"><span class="required">*</span> Dirección: </label>
        <input style="margin-left:2px;" name="calle" type="text" class="box" id="calle" size="45" value="<?=$calle;?>" />
        <label class="contactForm" style=" clear:left; width:60px; margin-left:10px;"><span class="required">*</span> Ciudad: </label>
        <input name="ciudad" type="text" class="box" id="ciudad" size="20" value="<?=$ciudad;?>" />
        <br />
        <label class="contactForm" style="width:55px; margin-left:14px;"><span class="required">*</span>Estado: </label>
        <input name="estado" type="text" class="box" id="estado" size="20" value="<?=$estado;?>" />
        <br />
        <label class="contactForm" style="clear:left; width:40px; margin-left:30px;"><span class="required">*</span>País: </label>
        <input  name="pais" type="text" class="box" id="pais" size="20" value="<?=$pais;?>" />
        <label class="contactForm" style="margin-left:3px; width:67px;" ><span class="required">*</span>Teléfono: </label>
        <input name="telefono"  type="text" class="box" id="telefono" size="20" value="<?=$telefono;?>" />
        <label class="contactForm" style="clear:left;"><span class="required">*</span> Mensaje: </label>
        <textarea name="message" cols="47" rows="4" class="box"  id="message"><?=$message;?>
</textarea>
        <br />
        
        <!-- Submit Button-->
        <input style="margin-left:205px; background-color:transparent;" name="send" type="submit" class="button" id="send" value="" />
        <a name="cont" id="cont"></a>
      </form>
      
      <!-- E-mail verification. Do not edit -->
      <?php
            }

            function isEmail($email)
            {
                return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i"
                        ,$email));
            }
            ?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.