Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics

Dashboard
Notifications
Mark all as read
Q&A

Creating a Right-To-Left, primarily-backend, HTML-PHP contact form

+0
−0

I host my website on a PaaS-modeled, shared hosting environment by SiteGround which is quite a well known hosting company with (as I believe) well-venerated email servers.


I am trying to create an RTL-first primarily backend HTML-PHP contact form.

If I use the following code I can submit the form and there is no error In the browser or in an autogenerated error log file but I also don't get an email.

What might be a problem in my latest code version below?

HTML

<!DOCTYPE html>
<html>
	<head>
		<title>יצירת קשר</title>
		<meta charset="utf-8">
		<link rel="stylesheet" href="./0_contact_form.css" type="text/css"></link>
		<!-- Normally scripts comes under the <body> tag but for a contact form file here is also fine -->
	</head>
	<body>
		<form dir="rtl" lang="he" method="POST" action="./0_contact_form.php" onsubmit="return redirectMe();" id="contact_form">
			<h2>יצירת קשר</h2>
			<p><label for="name" class="required">שם</label><input type="text" name="name" required id="cf_name"></input></p>
	<p><label for="email" class="required">כתובת אימייל</label><input type="email" name="email" required id="cf_email"></input></p>
			<p><label for="phone">מספר טלפון </label><input type="tel" name="phone" id="cf_phone"></input></p>
			<!-- SPECIFICALLY ADDED WHITESPACE TO מספר טלפון -->

			<p><label for="topic">פנייה בנושא</label> <select name="topic" id="cf_topic">
				<option value="אבחון קידום אתרים (כמפורט במחירון)">אבחון קידום אתרים (כמפורט במחירון)</option>
				<option value="שיווק באמצעות תוכן (כמפורט במחירון)">שיווק באמצעות תוכן (כמפורט במחירון)</option>
				<option value="פיתוח קישורים (כמפורט במחירון)">פיתוח קישורים (כמפורט במחירון)</option>
				<option value="ייעוץ והדרכה (כמפורט במחירון)">ייעוץ והדרכה (כמפורט במחירון)</option>
				<option value="נגישות">נגישות</option>
			</select></p>

			<label for="date">תאריך רצוי לפגישה (אם יש)</label> <input type="date" name="date" id="cf_date">

			<p><label for="notes">הערות (אם יש)</label> <input name="notes" type="text" id="cf_notes"/></p>
			<p><input type="submit" value="שליחה"></input></p>
		</form>
	</body>
</html>

CSS

.required:after {content:"* "; color: red;}

PHP

<?php
	$name = $_POST["name"];
	$email = $_POST["email"];
	$phone = $_POST["phone"];
	$topic = $_POST["topic"];
	$date = $_POST["date"];
	$notes = $_POST["notes"];

	$to = "[email protected]_TLD";
	$subject = "הודעת יצירת קשר";
	$message = array (
		$name . "שם" . "\r\n",
		$email . "אימייל" . "\r\n",
		$phone . "טלפון" . "\r\n",
		$topic . "פנייה בנושא" . "\r\n",
		$date . "תאריך רצוי לפגישה (אם יש)" . "\r\n",
		$notes . "הערות (אם יש)" . "\r\n"
	);
	$headers = array(
		"From" => $email,
		"Reply-To" => $email,
		"X-Mailer: PHP/" . phpversion()
	);
	# The order should be as above: $to, $subject, $message and $headers
	
	mail($to, $subject, $message, $headers);
?>
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

4 comments

There are many years since I have sent an e-mail using PHP, but I remember that e-mails required some kind of authentication to be treated correctly by the e-mail providers (they need to be sure that they come from the domain they seem to use). Failing to provide this, most of them reached the Spam folder. Alexei‭ 29 days ago

[This] might (https://stackoverflow.com/a/32413860/2780791) be relevant if my guess is right. Alexei‭ 29 days ago

Hello @Alexei. My infrastructure is PaaS by a well known hosting company (SiteGround) and I never had any problem sending mail through them with WordPress/Drupal/MediaWiki websites through the years. I also don't have anything in my Spam folder in Gmail. JohnDoea‭ 29 days ago

@JohnDoea‭ Ok, so they are handling authentication behind the scene. mail seems to return only true or false (success), so I think the only option is to check (or ask your provider to) the e-mail logs which should contain the cause of the error. Alexei‭ 29 days ago

0 answers

Sign up to answer this question »