Advertisement
Guest User

Untitled

a guest
Sep 6th, 2017
634
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.16 KB | None | 0 0
  1. function send_contact_mail($data)
  2. {
  3.     $data = array(
  4.         'firstName' => $data['firstName'],
  5.         'lastName'  => $data['lastName'],
  6.         'callName'  => $data['callName'],
  7.         'email'     => $data['email'],
  8.         'comment'   => $data['comment'],
  9.     );
  10.  
  11.  
  12.     $template = Timber::compile('templates/mail/contact_mail.twig', $data);
  13.  
  14.     $mail = new PHPMailer;                        // Enable verbose debug output
  15.  
  16.     $mail->isSMTP();                                      // Set mailer to use SMTP
  17.     //TODO change smtp server
  18. //    $mail->Host = 'smtp1.example.com;smtp2.example.com';  // Specify main and backup SMTP servers
  19. //    $mail->SMTPAuth = true;                               // Enable SMTP authentication
  20. //    $mail->Username = 'user@example.com';                 // SMTP username
  21. //    $mail->Password = 'secret';                           // SMTP password
  22. //    $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  23. //    $mail->Port = 587;                                    // TCP port to connect to
  24.  
  25.     $mail->Host = 'smtp.gmail.com';
  26.     $mail->Port = 587;
  27.     $mail->SMTPSecure = 'tls';
  28.     $mail->SMTPAuth = true;
  29.     $mail->Username = "testschool4us@gmail.com";
  30.     $mail->Password = "school4ustest";
  31.  
  32.     $mail->setFrom($data['email'], $data['firstName'] .' '. $data['lastName']);
  33.     $mail->addAddress('janmoes96@live.nl', 'School4us');     // Add a recipient
  34. //    $mail->addAddress('janmoes96@live.nl', 'School4us');     // Add a recipient
  35.     $mail->addReplyTo($data['email'], 'Contact');
  36. //    $mail->addCC('cc@example.com');
  37. //    $mail->addBCC('bcc@example.com');
  38.  
  39. //    $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
  40. //    $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
  41.     $mail->isHTML(true);                                  // Set email format to HTML
  42.  
  43.     $mail->Subject = 'Contact aanvraag';
  44.     $mail->Body = $template;
  45.     $mail->AltBody = $template; //$mail->AltBody = $template; //
  46.  
  47.     if (!$mail->send()) {
  48.         echo 'Message could not be sent.';
  49.         echo 'Mailer Error: ' . $mail->ErrorInfo;
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement