Skip to content

Instantly share code, notes, and snippets.

@Clndl
Created August 26, 2016 13:44
Show Gist options
  • Save Clndl/0c48c0d5b69455e861c3185d577f9249 to your computer and use it in GitHub Desktop.
Save Clndl/0c48c0d5b69455e861c3185d577f9249 to your computer and use it in GitHub Desktop.
<?php
require_once 'PHPMailer/class.phpmailer.php';
//On init global
$obj_return;
$obj_return->responseGET = $_GET;
//On init le mail
$mail = new PHPMailer;
$sendToEmail = "Email du destinataire"
$sendToName = "Nom du destinataire"
$sendToLastname = "Prénom du destinataire"
//On ajoute le destinataire
$mail->AddAddress($sendToEmail, $sendToName.' '.$sendFromLastName);
// Les infos d'envoie
$mail->From = 'contact@contact.com';
$mail->FromName = 'Google.com';
$subject = 'Coucou';
$bodyHtml = '<body></body>';
$bodyHtml .= getFooterMail();
$bodyText = "
Bonjour,\n\n
";
//On fait le contenu du mail
$mail->Subject = $subject;
$mail->Body = $bodyHtml;
$mail->AltBody = $bodyText;
//On fait la configuration du mail
$mail->IsHTML(true);
$mail->CharSet = 'UTF-8';
//On fait l'envoie
if(!$mail->Send()) {
$obj_return->response->status = "Message could not be sent.";
$obj_return->response->error = $mail->ErrorInfo;
}
else{
$obj_return->response->status = "Message has been sent";
}
//On return l'objet
header("Content-Type:application/json;charset=UTF-8");
echo json_encode($obj_return);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment