Advertisement
Guest User

Untitled

a guest
May 7th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. // Fonction gérant l'envois des mails...
  2. function sendMailTo($sender, $receiver, $url, $message)
  3. {
  4.     global $twig;
  5.  
  6.     $mail = new PHPMailer(true);
  7.  
  8.     try {
  9.         //Server settings
  10.         // $mail->SMTPDebug = 2;                                
  11.         $mail->isSMTP();
  12.         $mail->Host = 'smtp.gmail.com';
  13.         $mail->SMTPAuth = true;
  14.         $mail->CharSet = 'UTF-8';
  15.         $mail->Encoding = 'base64';
  16.         $mail->Username = 'swishfile.acs@gmail.com';
  17.         $mail->Password = 'online@2018';
  18.         $mail->SMTPSecure = 'tls';
  19.         $mail->Port = 587;
  20.  
  21.         //Recipients  
  22.         $mail->setFrom('swishfile.acs@gmail.com');
  23.  
  24.         // Pour le destinataire
  25.         $mail->addAddress($receiver);
  26.  
  27.         //Content
  28.         $mail->isHTML(true);
  29.         $mail->Subject = 'Une personne vous a envoyé des fichiers';
  30.         $mail->Body = $twig->render('mail.twig', array("url" => $url, "sender" => $sender, "message" => $message));
  31.  
  32.  
  33.         $mail->send();
  34.     } catch (Exception $e) {
  35.         echo "ERREUR ! Le message n'a pas été envoyé : ", $mail->ErrorInfo;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement