Advertisement
Guest User

Untitled

a guest
Jan 30th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1.             //Load Composer's autoloader
  2.             require 'vendor/autoload.php';
  3.  
  4.             $mail = new PHPMailer(true);                              // Passing `true` enables exceptions
  5.             try {
  6.                 //Server settings
  7.                 $mail->CharSet = 'UTF-8';
  8.                 //$mail->SMTPDebug = 1;                                 // Enable verbose debug output
  9.                 $mail->isSMTP();                                      // Set mailer to use SMTP
  10.                 $mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers
  11.                 $mail->SMTPAuth = true;                               // Enable SMTP authentication
  12.                 $mail->Username = 'adressedenvoi@gmail.com';                 // SMTP username
  13.                 $mail->Password = 'mdpducomptedenvoi';                           // SMTP password
  14.                 $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  15.                 $mail->Port = 587;                                    // TCP port to connect to
  16.                 //Recipients
  17.                 $mail->setFrom($email, 'Kustom Sofa');
  18.                 $mail->addAddress('emaildereception@gmail.com');     // Add a recipient
  19.                 //Content
  20.                 $mail->isHTML(true);                                  // Set email format to HTML
  21.                 $mail->Subject = 'sujet du mail';
  22.                 $mail->Body = 'corps du mail' . $message;
  23.                 if ($file != null)
  24.                     $mail->addAttachment('chemindufichier' . $file);
  25.                 $mail->send();
  26. //            echo 'Message has been sent';
  27.             } catch (Exception $e) {
  28. //            echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  29.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement