Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'PHPMailerAutoload.php';
- if(!empty($_POST['cw-name-b']) && !empty($_POST['cw-email-b'])){
- $name_valid = htmlspecialchars($_POST['cw-name-b'], ENT_QUOTES, 'UTF-8');
- $email_valid = filter_var($_POST['cw-email-b'], FILTER_VALIDATE_EMAIL);
- $sofa_width = htmlspecialchars($_POST['cw-sofa-width'], ENT_QUOTES, 'UTF-8');
- $sofa_width .= ' ' . htmlspecialchars($_POST['cw-sofa-width'], ENT_QUOTES, 'UTF-8');
- //$additional = htmlspecialchars($_POST['cw-yacs-additional-remarks'], ENT_QUOTES, 'UTF-8');
- $mail = new PHPMailer;
- $mail->Host = 'smtp.gmail.com'; // Specify main and backup server
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'askal.dima@gmail.com'; // SMTP username
- $mail->Password = '123456789!z#'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
- $mail->Port = 587; //Set the SMTP port number - 587 for authenticated TLS
- $mail->setFrom('askal.dima@gmail.com', 'Dmitri'); //Set who the message is to be sent from
- $mail->addAddress($email_valid); // Name is optional
- $mailResult = 'Name '. $name_valid.' Email ' . $email_valid. ' Sofa width '.$sofa_width;
- if (isset($_FILES['file-1']) && $_FILES['file-1']['error'] == UPLOAD_ERR_OK) {
- $file_count = count($_FILES['file-1']);
- for ($i=0; $i<$file_count; $i++) {
- $mail->AddAttachment($_FILES['file-1']['tmp_name'][$i], $_FILES['file-1']['name'][$i]);
- }
- }
- $mail->isHTML(true);
- $mail->msgHTML($mailResult);
- /*
- $mail->Host = 'smtp.gmail.com'; // Specify main and backup server
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'askal.dima@gmail.com'; // SMTP username
- $mail->Password = '123456789!z#'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
- $mail->Port = 587; //Set the SMTP port number - 587 for authenticated TLS
- $mail->setFrom('askal.dima@gmail.com', 'Dmitri');
- $mail->addAddress($email_valid, 'John Doe');
- $mailResult = 'Name '. $name_valid.' Email ' . $email_valid. ' Sofa width '.$sofa_width. ' Additional info ' . $additional;
- $mail->msgHTML($mailResult);
- */
- if (!$mail->send()) {
- echo "Mailer Error: " . $mail->ErrorInfo;
- } else {
- echo "Message sent!";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement