Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $data = file_get_contents("php://input");
- $dataAsJson = json_decode($data);
- $mail = new PHPMailer(true);
- try{
- $mail->IsSMTP();
- $mail->Mailer = "mail";
- $mail->SMTPAuth = true;
- $mail->Host = "smtp.ionos.fr";
- $mail->Port = 587; //465;
- $mail->SMTPDebug = 2;
- $mail->SMTPSecure = 'tls';
- $mail->Username = "******";
- $mail->Password = "******";
- $mail->Sender = "tpings@mydomain.fr";
- $mail->From = "tpings@mydomain.fr";
- $mail->AddAddress($dataAsJson->Email,$dataAsJson->Nom." ".$dataAsJson->Prenom);
- $mail->Subject = "Licence";
- $mail->FromName = "TPINGS Service";
- $mail->AddReplyTo('exemple@exemple.com', 'Contact TPINGS' );
- if($dataAsJson->English == true){
- $msg = "myMsg";
- $mail->AddAttachment("./uploads/Installation_EN.pdf");
- }else{
- $msg = "my_FR_msg";
- $mail->AddAttachment("./uploads/Installation_FR.pdf");
- }
- $mail->MsgHTML($msg);
- if(!$mail->Send()) {
- http_response_code(500);
- echo 'Erreur : ' . $mail->ErrorInfo;
- } else {
- http_response_code(200);
- }
- }catch(Exception $e){
- echo "Erreur mail : ".$mail->ErrorInfo;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement