Advertisement
Guest User

SMTP_PHPMAILER_FORMULARIOWEB

a guest
Dec 20th, 2015
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.03 KB | None | 0 0
  1.  
  2. *************************************************
  3. *****Código de la configuración del email********
  4. *************************************************
  5.  
  6. ```
  7. <?php
  8. if (isset($_POST['submitted'])) {
  9.    
  10.     include_once(ABSPATH . WPINC . '/class-phpmailer.php');
  11.  
  12.     $mail = new PHPMailer();
  13.     $mail->IsSMTP();
  14.     $mail->CharSet = 'UTF-8';
  15.  
  16.     $mail->Host = "smtp.gmail.com"; // SMTP server example
  17.     $mail->SMTPDebug = 0;                     // enables SMTP debug information (for testing)
  18.     $mail->SMTPAuth = true;                  // enable SMTP authentication
  19.     $mail->Port = 587;                    // set the SMTP port for the GMAIL server
  20.     $mail->Username = "miemail@gmail.com"; // SMTP account username example
  21.     $mail->Password = "mipassword";        // SMTP account password example
  22.     $mail->SMTPSecure = "tls";
  23.  
  24.     $to = $nt_option['contact_email'];
  25.     $subject = "Web Lluca Properties S.L";
  26.     $message = $_POST['description'];
  27.     $contactName = $_POST['contactName'];
  28.     $fromemail = $_POST['email'];
  29. //    $headers = 'MIME-Version: 1.0' . "\r\n";
  30. //    $headers = "From: $fromemail\n";
  31. //    $headers .= "Reply-to: $fromemail\n";
  32. //    $headers .= "Content-Type: text/html; charset=iso-8859-1\n";
  33.  
  34.     $mail->From = $fromemail;
  35.     $mail->FromName = $contactName;
  36.  
  37.     $mail->AddAddress($to);
  38.     $mail->IsHTML(false);
  39.     $mail->Subject = $subject;
  40.     $mail->Body = $message;
  41.     $result = $mail->Send();
  42.  
  43. //    if ($result) {
  44. //        echo "El correo fue enviado correctamente.";
  45. //    } else {
  46. //        echo "Hubo un inconveniente. Contacta a un administrador.";
  47. //    }
  48.  
  49.     if ($result) {
  50.         $emailSent = true;
  51.     }
  52. }
  53. ?>
  54. ```
  55.  
  56. *************************************************
  57. ************Código del formulario****************
  58. *************************************************
  59.  
  60. ```
  61. <form action="<?php the_permalink(); ?>" class="margin300" name="" method="post">
  62.                             <input type="hidden" name="submitted" id="submitted" value="true" />  
  63.                             <div class="form-group col-lg-6 col-lg-6 col-sm-6 col-xs-12">
  64.                                 <label><?php _e('Name', 'realto'); ?></label>
  65.                                 <div class="input-group">
  66.                                     <div class="input-group-addon"><i class="fa fa-user"></i></div>
  67.                                     <input class="form-control" required name="contactName" id="contactName" value="<?php if (isset($_POST['contactName'])) echo $_POST['contactName']; ?>" placeholder="<?php _e("Please, insert your name", "realto"); ?>" type="text">
  68.                                 </div>
  69.                             </div>    
  70.                             <div class="form-group col-lg-6 col-lg-6 col-sm-6 col-xs-12">
  71.                                 <label><?php _e('Email', 'realto'); ?></label>
  72.                                 <div class="input-group">
  73.                                     <div class="input-group-addon">@</div>
  74.                                     <input class="form-control" name="email" required id="email" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" placeholder="<?php _e("Please, insert your email", "realto"); ?>" type="email">
  75.                                 </div>
  76.                             </div>  
  77.                             <div class="form-group col-lg-12 col-md-12 col-sm-12 col-xs-12">
  78.                                 <label><?php _e('Message', 'realto'); ?></label>
  79.                                 <textarea class="form-control" name="description" placeholder="<?php _e("Write your message", "realto"); ?>" rows="6"><?php if (isset($_POST['description'])) echo $_POST['description']; ?></textarea>
  80.                             </div>
  81.                             <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
  82.                                 <input class="btn btn-realto span6" type="submit" name="submit" value="<?php _e("Submit", "realto"); ?>" />
  83.                             </div>
  84.                         </form>
  85. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement