I have a few questions regarding setting up a PHP mailer.... My first question being, does the PHP file/folders go in the same spot that all of my others (.html, css, and JS)?
If so, then I do indeed need some help setting this up, or am getting a little lost... My PHP file is as follows:
<?php
$emailTo = "myemail@yahoo.com"; // Enter your email for feedbacks here
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=utf-8\r\n";
$headers .= "From: ".$_POST['rsEmail']."\r\n";
if (!isset($_POST['rsSubject'])) {
$subject = "Contact Form Message"; // Enter your subject here
} else {
$subject = $_POST['rsSubject'];
}
reset($_POST);
$body = "";
$body .= "<p><b>Name: </b>".$_POST['rsName']."</p>";
$body .= "<p><b>Email: </b>".$_POST['rsEmail']."</p>";
$body .= "<p><b>Subject: </b>".$subject."</p>";
$body .= "<p><b>Message: </b>".$_POST['rsMessage']."</p>";
if( mail($emailTo, $subject, $body, $headers) ){
$mail_sent = true;
} else {
$mail_sent = false;
}
if(!isset($resp)){
echo json_encode($mail_sent);
}
?>
And I believe the corresponding javascript I have along with it is:
function isValidEmail(emailAddress) {
var pattern = /^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i;
return pattern.test(emailAddress);
};
Thank you guys for the assistance! Means a lot :)
Edit: When the form is filled out correctly, it says: "Congratulations your message was sent" -- meaning that it was a valid form submission, I just never actually get the email.
Edit 2: I went to my filezilla to try and edit/view the js file from there, I get the following error:
Not entirely sure what that entails (kind of newish to this all). Also here is my form:
<form class="rsForm" action="php/mailsender.php" method="post">
<div class="input-field">
<label>Name</label>
<input type="text" name="rsName" value="">
<span class="line"></span>
</div>
<div class="input-field">
<label>Email</label>
<input type="email" name="rsEmail" value="">
<span class="line"></span>
</div>
<div class="input-field">
<label>Subject</label>
<input type="text" name="rsSubject" value="">
<span class="line"></span>
</div>
<div class="input-field">
<label>Message</label>
<textarea rows="4" name="rsMessage"></textarea>
<span class="line"></span>
</div>
<span class="btn-outer btn-primary-outer ripple">
<input class="rsFormSubmit btn btn-lg btn-primary" type="submit" value="Send">
</span>
</form>