Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Load Composer's autoloader
- require 'vendor/autoload.php';
- $mail = new PHPMailer(true); // Passing `true` enables exceptions
- try {
- //Server settings
- $mail->CharSet = 'UTF-8';
- //$mail->SMTPDebug = 1; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'adressedenvoi@gmail.com'; // SMTP username
- $mail->Password = 'mdpducomptedenvoi'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 587; // TCP port to connect to
- //Recipients
- $mail->setFrom($email, 'Kustom Sofa');
- $mail->addAddress('emaildereception@gmail.com'); // Add a recipient
- //Content
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = 'sujet du mail';
- $mail->Body = 'corps du mail' . $message;
- if ($file != null)
- $mail->addAttachment('chemindufichier' . $file);
- $mail->send();
- // echo 'Message has been sent';
- } catch (Exception $e) {
- // echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement