Advertisement
Guest User

Untitled

a guest
Sep 6th, 2017
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1. <?php
  2.  
  3. require(__DIR__.'/../../vendor/phpmailer/phpmailer/PHPMailerAutoload.php');
  4.  
  5. function sendMail($template, $data){
  6.     $template = Timber::compile($template, $data);
  7.  
  8.     $mail = new PHPMailer;                        // Enable verbose debug output
  9.  
  10.     $mail->isSMTP();                                      // Set mailer to use SMTP     // TCP port to connect to
  11.  
  12.     $mail->Host = 'smtp.gmail.com';
  13.     $mail->Port = 587;
  14.     $mail->SMTPSecure = 'tls';
  15.     $mail->SMTPAuth = true;
  16.     $mail->Username = "testschool4us@gmail.com";
  17.     $mail->Password = "school4ustest";
  18.  
  19.     $mail->setFrom($data['email'], 'School4us');
  20.     $mail->addAddress($data['email'], 'School4us');     // Add a recipient
  21.     $mail->addReplyTo($email, 'Kopie inschrijving');
  22.  
  23.     $mail->isHTML(true);                                
  24.  
  25.     $mail->Subject = $data['subject'];
  26.     $mail->Body = $template;
  27.     $mail->AltBody = $template; //$mail->AltBody = $template; //
  28.  
  29.     if (!$mail->send()) {
  30.         echo 'Message could not be sent.';
  31.         echo 'Mailer Error: ' . $mail->ErrorInfo;
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement