Skip to content

Instantly share code, notes, and snippets.

@tmdarty
Last active October 29, 2019 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmdarty/cba24a0fce30ca6a080519830a14f7d2 to your computer and use it in GitHub Desktop.
Save tmdarty/cba24a0fce30ca6a080519830a14f7d2 to your computer and use it in GitHub Desktop.
Tuto : Comment envoyer des mails en PHPMailer[Testmail.php]
<?
//Inclure la classe PHPMailer
require "PHPMailer/PHPMailerAutoload.php";
function smtpmailer($to, $from, $from_name, $subject, $body)
{
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = 'smtp.server.com';
$mail->Port = 465;
$mail->Username = 'contact@votresite.com';
$mail->Password = 'votre_mot_de_passe';
$lien = 'votreducument.pdf';
$mail->AddAttachment($path);
$mail->IsHTML(true);
$mail->From="contact@votresite.com";
$mail->FromName=$from_name;
$mail->Sender=$from;
$mail->AddReplyTo($from, $from_name);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send())
{
$error ="Erreur...";
return $error;
}
else
{
$error = "Merci. Votre message a été bien envoyé.";
return $error;
}
}
//Envoie du mail
$to = 'utilisateur@gmail.com'
$from = 'contact@votresite.com';
$name = 'Le nom de votre site ou companie';
$subj = 'Ceci est un message de test pour PHPMailer';
$msg = 'Votre message ici';
$error=smtpmailer($to,$from, $name ,$subj, $msg);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment