Advertisement
Guest User

Untitled

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