I am trying to create a 'contact me' form by sending data in HTML form to an email address using php mail()
function.
I am using xampp and testing my code on localhost. I have installed Test Mail Server Tool and it is running on port 25.
Configuration of php.ini file
[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
; SMTP = smtp.secureserver.net
; smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = zain.farid@live.com
HTML Code
<form action="upload.php" method="post" style="height:100%">
<input name="articleTitle" value="Title" maxlength="50"
id="articleTitle">
<textarea name="article-body">
Compose your article...
</textarea>
<script>
CKEDITOR.inline( 'article-body' );
</script>
<input name="senderName" type="text" value="Name" maxlength="50"
id="name" class="textBox">
<input name="senderEmail" value="Email address" maxlength="50"
id="email" class="textBox">
<input name="abtyou" value="About Yourself" maxlength="150"
id="abtyou" class="textBox">
<input type="submit" name="submit" class="button">
</form>
PHP Code
<?php
$thankYou="";
if(isset($_POST["submit"])) {
$recipient="zain.farid@live.com";
$subject="New Guest Post";
$sender=$_POST["senderName"];
$senderEmail=$_POST["senderEmail"];
$senderAbout=$_POST["abtyou"];
$message=$_POST["article-body"];
$title=$_POST["articleTitle"];
$mailBody="Name: $sender\nEmail: $senderEmail\nAbout Sender: $senderAbout\nTitle: $title\n\n$message";
mail($recipient, $subject, $mailBody, "From: $sender <$senderEmail>");
$thankYou="Thank you! Your post has been submitted.";
}
?>
No error is reported but i cant see any email in my inbox of the mentioned email address. Can you please spot the error. I think its a configuration problem because i am using mail server for the first time and i think i might have made an error in configuration. Thank you