There is no error message - it just approves my entry, but message for approval is in english and I thought I translated it to different language in php files. There are messages sent though. The email for recipient is correct. I cleared cookies and tried again and it is the same still. My hosting provider approves php (from 5.3 to 7.4).
This is the php code:
<?php
header("Access-Control-Allow-Origin: *");
// Only process POST reqeusts.
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Get the form fields and remove whitespace.
$name = strip_tags(trim($_POST["con_name"]));
$name = str_replace(array("\r","\n"),array(" "," "),$name);
$email = filter_var(trim($_POST["con_email"]), FILTER_SANITIZE_EMAIL);
$phone = trim($_POST["con_phone"]);
$message = trim($_POST["con_message"]);
// Check that data was sent to the mailer.
if ( empty($name) OR empty($message) OR !filter_var($email, FILTER_VALIDATE_EMAIL)) {
// Set a 400 (bad request) response code and exit.
http_response_code(400);
echo "Coś poszło nie tak. Proszę, uzupełnij formularz i spróbuj ponownie.";
exit;
}
// Set the recipient email address.
$recipient = "lynx.tworzeniestron@gmail.com";
// Set the email subject.
$subject = "tworzeniestron.net.pl - $name";
// Build the email content.
$email_content =
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Contact Mail</title>
<!--[if (mso)|(mso 16)]>
<style type="text/css">
body, table, td, a, span { font-family: Arial, sans-serif !important; }
a {text-decoration: none !important;}
</style>
<![endif]-->
<style type="text/css">
/* CLIENT-SPECIFIC STYLES */
body,
table,
td,
a {
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
table,
td {
mso-table-lspace: 0pt;
mso-table-rspace: 0pt;
}
img {
-ms-interpolation-mode: bicubic;
}
/* RESET STYLES */
img {
border: 0;
outline: none;
text-decoration: none;
}
table {
border-collapse: collapse !important;
}
body {
color: #626160!important;
font-family: Tahoma, Arial, sans-serif !important;
font-size: 14px;
margin: 0 !important;
padding: 0 !important;
width: 100% !important;
}
h1,
h2,
h3,
h4,
h5,
h6,
p,
img {
margin: 0;
padding: 0;
}
/* iOS BLUE LINKS */
a[x-apple-data-detectors] {
color: inherit !important;
text-decoration: none !important;
font-size: inherit !important;
font-family: inherit !important;
font-weight: inherit !important;
line-height: inherit !important;
}
/* ANDROID CENTER FIX */
div[style*="margin: 16px 0;"] {
margin: 0 !important;
}
/* MEDIA QUERIES */
@media all and (max-width:639px) {
.wrapper {
width: 320px!important;
padding: 0 !important;
}
.container {
width: 300px!important;
padding: 0 !important;
}
.mobile {
width: 300px!important;
display: block!important;
padding: 0 !important;
}
.img {
width: 100% !important;
height: auto !important;
}
*[class="mobileOff"] {
width: 0px !important;
display: none !important;
}
*[class*="mobileOn"] {
display: block !important;
max-height: none !important;
}
}
/*===========================
Author Custom Style
============================*/
hr{
border-color: #fefefe;
border-width: 1px;
margin-bottom: 10px;
}
.message-content{
font-size: 16px;
line-height: 1.6;
}
.content-wrapper h2{
font-weight: 400;
font-size: 20px;
}
.email-txt a{
color: #222222 !important;
text-decoration: none !important;
}
</style>
</head>
<body style="margin:0; padding:0; background-color:#F3F3F3;">
<center>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F2F2F2">
<tr>
<td height="100" style="font-size:10px; line-height:10px;"> </td>
</tr>
<tr>
<td align="center" valign="top">
<!--== TemplateContainer Start ==-->
<table width="600" cellpadding="0" cellspacing="0" border="0" class="wrapper" bgcolor="#FFFFFF">
<tr>
<td height="60" style="font-size:10px; line-height:10px;"> </td>
</tr>
<!--== Content Area Start ==-->
<tr class="content-wrapper">
<td align="center" valign="top">
<table width="560" cellpadding="0" cellspacing="0" border="0" class="container">
<!--== Start Name Field Item ==-->
<tr>
<td width="100%" class="mobile" align="left" valign="middle">
<h3>Name:</h3>
<hr>
<h2>' . $name .'</h2>
</td>
</tr>
<!--== End Name Field Item ==-->
<!--== Start Separator ==-->
<tr>
<td height="30" style="font-size:10px; line-height:10px;"> </td>
</tr>
<!--== End Separator ==-->
<!--== Start Email Field Item ==-->
<tr>
<td width="100%" class="mobile" align="left" valign="middle">
<h3>Email:</h3>
<hr>
<h2 class="email-txt">'. $email .'</h2>
</td>
</tr>
<!--== Start Email Field Item ==-->
<!--== Start Separator ==-->
<tr>
<td height="30" style="font-size:10px; line-height:10px;"> </td>
</tr>
<!--== End Separator ==-->
<!--== Start Phone Field Item ==-->
<tr>
<td width="100%" class="mobile" align="left" valign="middle">
<h3>Phone or Mobile:</h3>
<hr>
<h2>'. $phone .'</h2>
</td>
</tr>
<!--== End Phone Field Item ==-->
<!--== Start Separator ==-->
<tr>
<td height="30" style="font-size:10px; line-height:10px;"> </td>
</tr>
<!--== End Separator ==-->
<!--== Start Subject Field Item ==-->
<tr>
<td width="100%" class="mobile" align="left" valign="middle">
<h3>Subject:</h3>
<hr>
<h2>'. $subject .'</h2>
</td>
</tr>
<!--== End Subject Field Item ==-->
<!--== Start Separator ==-->
<tr>
<td height="30" style="font-size:10px; line-height:10px;"> </td>
</tr>
<!--== End Separator ==-->
<!--== Start Message Field Item ==-->
<tr>
<td width="100%" class="mobile" align="left" valign="middle">
<h3>Message:</h3>
<hr>
<p class="message-content">'. $message .'</p>
</td>
</tr>
<!--== End Message Field Item ==-->
</table>
</td>
</tr>
<!--== Content Area End ==-->
<tr>
<td height="60" style="font-size:10px; line-height:10px;"> </td>
</tr>
</table>
<!--== TemplateContainer End ==-->
</td>
</tr>
<tr>
<td height="20" style="font-size:10px; line-height:10px;"> </td>
</tr>
<tr>
<td align="center" valign="top">
<a href="https://hasthemes.com/" target="_blank"><img width="120" src="https://hasthemes.com/wp-content/uploads/2019/01/1.png" alt="HasThemes"></a>
</td>
</tr>
<tr>
<td height="100" style="font-size:10px; line-height:10px;"> </td>
</tr>
</table>
</center>
</body>
</html>';
// Build the email headers.
$email_headers = "MIME-Version: 1.0" . "\r\n";
$email_headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$email_headers .= 'From:' . $name . ' ' . 'noreply@yourdomain.com' . "\r\n";
$email_headers .= 'Reply-To:' . $email . "\r\n";
// Send the email.
if (mail($recipient, $subject, $email_content, $email_headers)) {
// Set a 200 (okay) response code.
http_response_code(200);
echo "Dziękuję! ".$name." , Twoja wiadomość została wysłana.";
} else {
// Set a 500 (internal server error) response code.
http_response_code(500);
echo "Ups! Coś poszło nie tak i Twój email nie został wysłany.";
}
} else {
// Not a POST request, set a 403 (forbidden) response code.
http_response_code(403);
echo "Był problem z Twoim zgłoszeniem. Proszę, spróbuj ponownie.";
}
?>
And there is html code as well (action link was leading to some specific url with this php file, but it didn't work anyway and I thought it should lead to the local file. The path leads to it now). HTML code:
<div class="contact-form">
<form
class="contact-form-wrapper"
id="contact-form"
action="/assets/php/mail.php"
method="post"
>
<div class="row">
<div class="col-lg-12">
<div class="section-title">
<div class="subtitle-content">
<img src="assets/img/shape/line-s4.png" alt="" />
<h5 class="text-light">Odezwij się</h5>
</div>
<h2 class="title text-light">
Jak możemy Ci <span>pomóc?</span>
</h2>
<div class="separator-line">
<img src="assets/img/shape/line-s4.png" alt="" />
<img src="assets/img/shape/line-s4.png" alt="" />
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="row row-gutter-20">
<div class="col-md-12">
<div class="form-group">
<input
class="form-control"
type="text"
name="con_name"
placeholder="Imię i nazwisko"
/>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<input
class="form-control"
type="email"
name="con_email"
placeholder="Email"
/>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<input
class="form-control"
type="text"
name="con_phone"
placeholder="Numer telefonu"
/>
</div>
</div>
<div class="col-md-12">
<div class="form-group mb-0">
<textarea
name="con_message"
placeholder="Jak możemy Ci pomóc?"
></textarea>
</div>
</div>
<div class="col-md-12">
<div class="form-group mb-0">
<button class="btn btn-theme" type="submit">
Wysyłam wiadomość
<i class="icofont-long-arrow-right"></i>
</button>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<!-- Message Notification -->
<div class="form-message"></div>