feat/send-mail-to-member #81

Merged
florent.lesaout merged 10 commits from feat/send-mail-to-member into master 2024-03-20 14:04:39 +01:00
Showing only changes of commit 0b6c22c7a3 - Show all commits

View File

@ -7,6 +7,21 @@ $mail = new PHPMailer(true);
$errors = '';
$myEmail = getenv('ASTRO_SMTP_FROM');
$myEmailSplitted = explode('@', $myEmail);
$domainFromMyEmail = (
empty($myEmailSplitted[1])
|| count($myEmailSplitted) != 2
) ? ''
: $myEmailSplitted[1];
$wantedContact = filter_input(INPUT_POST, 'contactTo', FILTER_VALIDATE_EMAIL);
if (
empty($wantedContact)
|| empty($domainFromMyEmail)
|| substr($wantedContact, -strlen($domainFromMyEmail)) != $domainFromMyEmail
) {
$wantedContact = $myEmail;
}
if(empty($_POST['namezzz']) || empty($_POST['emailzzz']) || empty($_POST['message'])) {
$errors .= "\n Error: all fields are required";
@ -27,7 +42,6 @@ if (!filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) {
}
if(empty($errors)) {
$to = $myEmail;
$emailSubject = "[Formulaire Astrolabe] Nouveau message";
switch ($select) {
@ -66,7 +80,7 @@ if(empty($errors)) {
//Recipients
$mail->setFrom($myEmail);
$mail->addAddress($myEmail);
$mail->addAddress($wantedContact);
$mail->addReplyTo($emailAddress, $name);
// Content