Advertisement
Guest User

Untitled

a guest
Sep 6th, 2017
587
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.91 KB | None | 0 0
  1. <?php
  2. require(__DIR__.'/../../vendor/phpmailer/phpmailer/PHPMailerAutoload.php');
  3.  
  4. function send_contact_mail($data)
  5. {
  6.  
  7.     $template = Timber::compile('templates/mail/contact_mail.twig', $data);
  8.  
  9.     $mail = new PHPMailer;                        // Enable verbose debug output
  10.  
  11.     $mail->isSMTP();                                      // Set mailer to use SMTP
  12.     //TODO change smtp server
  13. //    $mail->Host = 'smtp1.example.com;smtp2.example.com';  // Specify main and backup SMTP servers
  14. //    $mail->SMTPAuth = true;                               // Enable SMTP authentication
  15. //    $mail->Username = 'user@example.com';                 // SMTP username
  16. //    $mail->Password = 'secret';                           // SMTP password
  17. //    $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  18. //    $mail->Port = 587;                                    // TCP port to connect to
  19.  
  20.     $mail->Host = 'smtp.gmail.com';
  21.     $mail->Port = 587;
  22.     $mail->SMTPSecure = 'tls';
  23.     $mail->SMTPAuth = true;
  24.     $mail->Username = "testschool4us@gmail.com";
  25.     $mail->Password = "school4ustest";
  26.  
  27.     $mail->setFrom($data['email'], $data['firstName'] .' '. $data['lastName']);
  28.     $mail->addAddress('janmoes96@live.nl', 'School4us');     // Add a recipient
  29. //    $mail->addAddress('janmoes96@live.nl', 'School4us');     // Add a recipient
  30.     $mail->addReplyTo($data['email'], 'Contact');
  31. //    $mail->addCC('cc@example.com');
  32. //    $mail->addBCC('bcc@example.com');
  33.  
  34. //    $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
  35. //    $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
  36.     $mail->isHTML(true);                                  // Set email format to HTML
  37.  
  38.     $mail->Subject = 'Contact aanvraag';
  39.     $mail->Body = $template;
  40.     $mail->AltBody = $template; //$mail->AltBody = $template; //
  41.  
  42.     if (!$mail->send()) {
  43.         echo 'Message could not be sent.';
  44.         echo 'Mailer Error: ' . $mail->ErrorInfo;
  45.     }
  46. }
  47.  
  48. function send_contact_mail_client($email)
  49. {
  50.  
  51.     $template = Timber::compile('templates/mail/contact_mail_client.twig', $data);
  52.  
  53.     $mail = new PHPMailer;                        // Enable verbose debug output
  54.  
  55.     $mail->isSMTP();                                      // Set mailer to use SMTP
  56.     //TODO change smtp server
  57. //    $mail->Host = 'smtp1.example.com;smtp2.example.com';  // Specify main and backup SMTP servers
  58. //    $mail->SMTPAuth = true;                               // Enable SMTP authentication
  59. //    $mail->Username = 'user@example.com';                 // SMTP username
  60. //    $mail->Password = 'secret';                           // SMTP password
  61. //    $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  62. //    $mail->Port = 587;                                    // TCP port to connect to
  63.  
  64.     $mail->Host = 'smtp.gmail.com';
  65.     $mail->Port = 587;
  66.     $mail->SMTPSecure = 'tls';
  67.     $mail->SMTPAuth = true;
  68.     $mail->Username = "testschool4us@gmail.com";
  69.     $mail->Password = "school4ustest";
  70.  
  71.     $mail->setFrom($email, 'School4us');
  72.     $mail->addAddress($email, 'School4us');     // Add a recipient
  73. //    $mail->addAddress('janmoes96@live.nl', 'School4us');     // Add a recipient
  74.     $mail->addReplyTo($email, 'Kopie inschrijving');
  75. //    $mail->addCC('cc@example.com');
  76. //    $mail->addBCC('bcc@example.com');
  77.  
  78. //    $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
  79. //    $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
  80.     $mail->isHTML(true);                                  // Set email format to HTML
  81.  
  82.     $mail->Subject = 'Uw inschrijving';
  83.     $mail->Body = $template;
  84.     $mail->AltBody = $template; //$mail->AltBody = $template; //
  85.  
  86.     if (!$mail->send()) {
  87.         echo 'Message could not be sent.';
  88.         echo 'Mailer Error: ' . $mail->ErrorInfo;
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement