Advertisement
Guest User

Untitled

a guest
Mar 21st, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.52 KB | None | 0 0
  1. require 'PHPMailerAutoload.php';
  2.  
  3. if(!empty($_POST['cw-name-b']) && !empty($_POST['cw-email-b'])){
  4.     $name_valid = htmlspecialchars($_POST['cw-name-b'], ENT_QUOTES, 'UTF-8');
  5.     $email_valid = filter_var($_POST['cw-email-b'], FILTER_VALIDATE_EMAIL);
  6.     $sofa_width = htmlspecialchars($_POST['cw-sofa-width'], ENT_QUOTES, 'UTF-8');
  7.     $sofa_width .= ' ' . htmlspecialchars($_POST['cw-sofa-width'], ENT_QUOTES, 'UTF-8');
  8.     //$additional = htmlspecialchars($_POST['cw-yacs-additional-remarks'], ENT_QUOTES, 'UTF-8');
  9.     $mail = new PHPMailer;
  10.  
  11.  
  12. $mail->Host = 'smtp.gmail.com';                       // Specify main and backup server
  13. $mail->SMTPAuth = true;                               // Enable SMTP authentication
  14. $mail->Username = 'askal.dima@gmail.com';                   // SMTP username
  15. $mail->Password = '123456789!z#';               // SMTP password
  16. $mail->SMTPSecure = 'tls';                            // Enable encryption, 'ssl' also accepted
  17. $mail->Port = 587;                                    //Set the SMTP port number - 587 for authenticated TLS
  18. $mail->setFrom('askal.dima@gmail.com', 'Dmitri');     //Set who the message is to be sent from
  19. $mail->addAddress($email_valid);               // Name is optional
  20. $mailResult = 'Name '. $name_valid.' Email ' . $email_valid. ' Sofa width '.$sofa_width;
  21.  
  22. if (isset($_FILES['file-1']) && $_FILES['file-1']['error'] == UPLOAD_ERR_OK) {
  23.         $file_count = count($_FILES['file-1']);
  24.         for ($i=0; $i<$file_count; $i++) {
  25.             $mail->AddAttachment($_FILES['file-1']['tmp_name'][$i], $_FILES['file-1']['name'][$i]);
  26.         }
  27.     }
  28.  
  29. $mail->isHTML(true);                          
  30. $mail->msgHTML($mailResult);
  31.  
  32. /*
  33.     $mail->Host = 'smtp.gmail.com';                       // Specify main and backup server
  34.     $mail->SMTPAuth = true;                               // Enable SMTP authentication
  35.     $mail->Username = 'askal.dima@gmail.com';       // SMTP username
  36.     $mail->Password = '123456789!z#';               // SMTP password
  37.     $mail->SMTPSecure = 'tls';                          // Enable encryption, 'ssl' also accepted
  38.     $mail->Port = 587;                                    //Set the SMTP port number - 587 for authenticated TLS
  39.     $mail->setFrom('askal.dima@gmail.com', 'Dmitri');  
  40.     $mail->addAddress($email_valid, 'John Doe');
  41.     $mailResult = 'Name '. $name_valid.' Email ' . $email_valid. ' Sofa width '.$sofa_width. ' Additional info ' . $additional;
  42.     $mail->msgHTML($mailResult);
  43. */
  44.     if (!$mail->send()) {
  45.         echo "Mailer Error: " . $mail->ErrorInfo;
  46.     } else {
  47.         echo "Message sent!";
  48.     }
  49.    
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement