feat/send-mail-to-member #81
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user