Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Set correct timezone
- date_default_timezone_set('Europe/Helsinki');
- $timezone = date_default_timezone_get();
- $date = date('d.m.Y H:i', time());
- $data = json_decode(file_get_contents('php://input'), true);
- if ($data) {
- $contact_message = $data["message"];
- $contact_name = $data["name"];
- $contact_phone = $data["phone"];
- $contact_email = $data["email"];
- $email_is_valid = filter_var($contact_email, FILTER_VALIDATE_EMAIL);
- if ($email_is_valid) {
- // Send email to drivers
- $to = 'teemuvikstrom@gmail.com';
- $subject = 'Yhteydenottolomake ' . $date;
- $message = "
- Yhteydenottolomake specialtaxitalja.fi:stä:
- Nimi: " . $contact_name . "
- Puhelin: " . $contact_phone . "
- Email: " . $contact_email . "
- Viesti:
- " . $contact_message . "
- Viesti lähetetty: " . $date . "
- Vierailijan IP: " . $_SERVER["REMOTE_ADDR"];
- $headers = 'From: teemuvikstrom@gmail.com' . "\r\n" .
- 'Reply-To: teemuvikstrom@gmail.com' . "\r\n" .
- 'X-Mailer: PHP/' . phpversion();
- $mail_sending_result = mail($to, $subject, $message, $headers);
- // Return success message
- http_response_code(200);
- header('Content-Type: application/json');
- echo '{ "success": true, "response": "' . $mail_sending_result . '" }';
- } else {
- http_response_code(400);
- header('Content-Type: application/json');
- echo '{ "success": false, "detail": "Sähköposti ei kelpaa!" }';
- }
- } else {
- http_response_code(400);
- header('Content-Type: application/json');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement