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
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

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

Post

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_ADDRESS@EMAIL_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);
?>
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

General comments (4 comments)
General comments
Alexei‭ wrote over 3 years ago

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‭ wrote over 3 years ago · edited over 3 years ago

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

deleted user wrote over 3 years 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.

Alexei‭ wrote over 3 years 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.