TeleQom.org/php/contact.php

49 lines
1.6 KiB
PHP
Raw Normal View History

2023-03-15 19:53:04 +00:00
<?php
2023-04-23 21:45:05 +00:00
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
2023-06-12 19:47:02 +00:00
require '../config/PRIVATE/contact.php';
2023-04-23 21:45:05 +00:00
2023-03-15 19:53:04 +00:00
$lang_folder = $_GET['contact-language']=="en"?"/pages/en/":"/pages/fr/";
if(!filter_var($_GET['contact-email'], FILTER_VALIDATE_EMAIL) || strlen($_GET['contact-message'])==0 || strlen($_GET['contact-name'])==0 || $_GET['contact-email-2'] != ""){
header("Location: ".$lang_folder."err/contact.html");
die();
}
2023-04-23 21:45:05 +00:00
2023-06-12 19:52:30 +00:00
$receiver_email = $smtp_to_email;
2023-03-15 19:53:04 +00:00
$message = "Contact: ".$_GET['contact-name']."\nEmail: ".$_GET['contact-email']."\nMessage:\n".$_GET['contact-message'];
2023-04-23 21:45:05 +00:00
$mail = new PHPMailer(true);
try{
$mail->isSMTP();
2023-06-12 19:52:30 +00:00
$mail->Host = $smtp_host;
2023-04-23 21:45:05 +00:00
$mail->SMTPAuth = true;
2023-06-12 19:52:30 +00:00
$mail->Username = $smtp_username;
2023-06-12 19:47:02 +00:00
$mail->Password = $smtp_password;
2023-04-23 21:45:05 +00:00
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;
2023-06-12 19:52:30 +00:00
$mail->setFrom($smtp_from_email, 'Mailer');
2023-04-23 21:45:05 +00:00
$mail->addAddress($receiver_email);
$mail->addReplyTo($_GET['contact-email'], $_GET['contact-name']);
$mail->isHTML(false);
$mail->Subject = 'Contact TeleQom.org';
$mail->Body = $message;
$mail->AltBody = $message;
$mail->send();
header("Location: ".$lang_folder."confirmation.html");
}catch (Exception $e) {
header("Location: ".$lang_folder."err/contact.html");
die();
}
2023-03-15 19:53:04 +00:00
?>