-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_email.php
More file actions
31 lines (27 loc) · 949 Bytes
/
send_email.php
File metadata and controls
31 lines (27 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
// Tarkistetaan, että lomake lähetti tiedot
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Haetaan lomakkeen tiedot
$name = htmlspecialchars($_POST["name"]);
$email = htmlspecialchars($_POST["email"]);
$message = htmlspecialchars($_POST["message"]);
// Määritetään vastaanottajan sähköpostiosoite
$to = "jyri.2.nieminen@tuno.fi";
$subject = "Yhteydenottopyyntö: $name";
// Sähköpostin sisältö
$body = "Saat viestin verkkosivultasi:\n\n";
$body .= "Nimi: $name\n";
$body .= "Sähköposti: $email\n\n";
$body .= "Viesti:\n$message\n";
// Määritetään lähettäjän tiedot
$headers = "From: $email";
// Lähetetään sähköposti
if (mail($to, $subject, $body, $headers)) {
echo "Viesti lähetettiin onnistuneesti.";
} else {
echo "Viestin lähettäminen epäonnistui.";
}
} else {
echo "Virhe: Lomaketta ei lähetetty oikein.";
}
?>