1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHPMailer - GMail SMTP test</title>
</head>
<body>
<?php
date_default_timezone_set('Etc/UTC');
require '../class.phpmailer.php';
$mail = new PHPMailer();
$mail->IsSMTP(); //Enable SMTP debugging
$mail->SMTPDebug = 2; // 0 = off (for production use)
$mail->Debugoutput = 'html'; // 1 = client messages
$mail->Host = 'smtp.gmail.com'; // 2 = client and server messages
$mail->Port = 587; // ou 465
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "monmail@gmail.com";
$mail->Password = "monpassword";
$mail->SetFrom('client@mail.fr', 'client');
//$mail->AddReplyTo('replyto@example.com','First Last');
$mail->AddAddress('monmail@gmail.com', 'Moi');
$mail->Subject = 'PHPMailer GMail SMTP test';
$mail->MsgHTML(file_get_contents('contents.html'), dirname(__FILE__));
$mail->AltBody = 'This is a plain-text message body';
$mail->AddAttachment('images/phpmailer_mini.gif');
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
}
else {
echo "Message sent!";
}
?>
</body>
</html> |
Partager