* Αυτά τα πεδιά απαιτούνται.
if ($_SERVER["REQUEST_METHOD"] === "POST") {
// an email address that will be in the From field of the email.
$fromEmail = 'contact@summerfestivals.gr';
$fromName = 'Contact form';
// an email address that will receive the email with the output of the form
//$sendToEmail = 'stamatis@epinoisis.edu.gr';
$sendToEmail = $_POST['need'];
//ορίζουμε την διεύθυνση απάντησης της ερώτησης.
$from=$_POST['email'];
$sendToName = '';
// subject of the email
$subject = 'Νέο μήνυμα από φόρμα επικοινωνίας Syndramo';
// form field names and their translations.
// array variable name => Text to appear in the email
$fields = array('name' => 'Name', 'surname' => 'Surname', 'phone' => 'Phone', 'email' => 'Email', 'message' => 'Message');
// message that will be displayed when everything is OK :)
$okMessage = 'Η φόρμα επικοινωνίας συμπληρώθηκε επιτυχώς. Ευχαριστούμε, θα επικοινωνήσουμε σύντομα!';
// If something goes wrong, we will display this message.
$errorMessage = 'Υπήρχε κάποιο σφάλμα κατά την καταχώρηση της φόρμας. Παρακαλώ δοκιμάστε ξανά σε λίγο.';
$emailTextHtml = "
Έχεις ένα νέο μήνυμα από την φόρμα επικοινωνίας
";
$emailTextHtml .= "
";
foreach ($_POST as $key => $value) {
// If the field exists in the $fields array, include it in the email
if (isset($fields[$key])) {
$emailTextHtml .= "$fields[$key] | $value |
";
}
}
$emailTextHtml .= "
";
$emailTextHtml .= "
Σιγουρέψου ότι απαντάς στο email της ερώτησης,
Σταμάτης Χατζηχριστοδούλου
";
//$mail->addAddress($row['email'],$row['lastname']);
$mail->addAddress($sendToEmail, $sendToName); // you can add more addresses by simply adding another line with $mail->addAddress();
$mail->addReplyTo($from);
$mail->Subject = $subject;
$mail->msgHTML($emailTextHtml); // this will also create a plain-text version of the HTML email, very handy
if(!$mail->send()) {
throw new \Exception('I could not send the email.' . $mail->ErrorInfo);
echo '
Error
';
}
else { //επιτυχία στην εντολή
echo '
Επιτυχής αποστολή
';
}
$responseArray = array('type' => 'success', 'message' => $okMessage);
$mail->ClearAddresses();
}
?>