Advertisement
Guest User

Untitled

a guest
Feb 15th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.60 KB | None | 0 0
  1. if (!$lastnameErr && !$firstnameErr && !$emailErr)
  2.         {
  3.             // Set time zone
  4.             date_default_timezone_set('Etc/UTC');
  5.             // Require PHPMailer
  6.             require_once('phpmailer.php');
  7.             // GET posted fields
  8.             $lastname  = $_POST['contact']['lastname'];
  9.             $firstname = $_POST['contact']['firstname'];
  10.             $email     = $_POST['contact']['email'];
  11.             $phone     = $_POST['contact']['phone'];
  12.             $message   = $_POST['contact']['message'];
  13.  
  14.             $subject   = "Email de contact Peregrina fr";
  15.             $body      = "De: " . ucfirst($lastname) . " " . ucfirst($firstname) . "\nE-mail: " . $email . "\nTel: " . $phone . "\n\nMessage:\n" . $message;
  16.  
  17.             $mail = new PHPMailer();
  18.             $mail->isSMTP();                                 // Set mailer to use SMTP
  19.             $mail->Host = 'smtp.gmail.com';                  // Specify main and backup SMTP servers
  20.             $mail->Port = 587;                               // TCP port to connect to
  21.             $mail->SMTPSecure = 'tls';                       // Enable TLS encryption, `ssl` also accepted
  22.             $mail->SMTPAuth = true;                          // Enable SMTP authentication
  23.             $mail->Username = 'peregrinamailsite@gmail.com'; // SMTP username
  24.             $mail->Password = 'powerball';                   // SMTP password
  25.             $mail->setFrom('contact@site-peregrina.fr', 'Contact Peregrina');
  26.             $mail->addAddress('xl@xavierleonard.fr');
  27.             $mail->addBCC('xl@peregrina.fr');
  28.             $mail->addBCC('natsensxl@gmail.com');
  29.             $mail->addBCC('yves@yateo.com');
  30.             $mail->Subject = $subject;
  31.             $mail->Body = $body;
  32.  
  33.             if(!$mail->send()) {
  34.                 $mailSent = false;
  35.             } else {
  36.                 $mailSent = true;
  37.             }
  38.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement