mail.php 929 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. require 'phpmailer/PHPMailerAutoload.php';
  3. include_once ('tools/util.php');
  4. function send_forgotten_mail($email, $username, $link) {
  5. if (!isset($ini)) {
  6. $ini = read_config ();
  7. }
  8. $mail = new PHPMailer ();
  9. $mail->isSMTP (); // Set mailer to use SMTP
  10. $mail->Host = $ini ["mail_server"]; // Specify main and backup SMTP servers
  11. $mail->SMTPAuth = true; // Enable SMTP authentication
  12. $mail->Username = $ini ["mail_user"]; // SMTP username
  13. $mail->Password = $ini ["mail_pwd"]; // SMTP password
  14. //$mail->SMTPSecure = 'ssl'; // Enable encryption, 'ssl' also accepted
  15. //$mail->Port = 465;
  16. $mail->From = $ini ["mail_from"];
  17. $mail->FromName = 'Mailer';
  18. $mail->addAddress ( $email ); // Add a recipient
  19. $mail->Subject = 'Reset password';
  20. $mail->Body = 'You can reset your password with this link: ' . $link;
  21. //$mail->SMTPDebug = 2;
  22. if (! $mail->send ()) {
  23. return false;
  24. } else {
  25. return true;
  26. }
  27. }
  28. ?>