954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

My form data not going through email...

Hai there,

I have doing php code for form data to be send to email.
But it is showing...

Your message could not be sent at this time. Please try again.

Here is my code for html form...

<body>

	<div id="emailform">
		<form action="email-thankyou.php" method="post" name="contactForm" onsubmit="return validateForm(this);">
			<p><strong>Name:</strong> <input name="name" type="text" size="40" /></p>
			<p><strong>Email:</strong> <input name="email" type="text" size="40" /></p>
			<p><strong>Message:</strong></p>
			<p><textarea name="message" rows="4" cols="50"></textarea></p>
			<div id="buttons"><input type="submit" value="Send Email">&nbsp;&nbsp;<input type="reset" value="Reset"></div>
		</form>
	</div>
				
</body>


Here is my code for php file....

<?php 
  
    // Grab the form vars 
    $email = (isset($_POST['email'])) ? $_POST['email'] : '' ; 
    $message = (isset($_POST['message'])) ? $_POST['message'] : '' ; 
    $name = (isset($_POST['name'])) ? $_POST['name'] : '' ; 
  
    // Check for email injection 
    if (has_emailheaders($email)) { 
        die("Possible email injection occuring"); 
    } 
  
    $sent = @mail("ssmeshack@gmail.com", "Subject of the email ", "Name: $name\n Email: $email\n\n $message", "From: $email"); 
  
        if ($sent ) {  
            echo "Thank you for your inquiry, Your message has been received. We will get back to you as soon as we can.";  
        } else {  
            echo "Your message could not be sent at this time. Please try again.";  
        } 
function has_emailheaders($text) { 
    return preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i", $text); 
} 
?>


Is it because im using yahoomail or gmail as a receiver's email?
Please help me....
Im a newbie in php coding.

Regards,
Meshack

ssmeshack
Newbie Poster
4 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

Are you sure, you can use the mail function?
some servers block it fort spam reasons.

Kruptein
Posting Whiz in Training
258 posts since Sep 2009
Reputation Points: 25
Solved Threads: 11
 
Are you sure, you can use the mail function? some servers block it fort spam reasons.

hai there,
thanks for the reply...
yes. it really dont the send the data to email...
how about if I use own email server... like company...
but i dont understand 1 thing....
what is mail function?

thanks

ssmeshack
Newbie Poster
4 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

You are using a certain function called mail()

$sent = @mail(...)


This is a built-in function off php, but can be turned off, to check if it is turned off, do phpinfo() and check if it is enabled.
I don't know what the @ is doing in front of the mail, I just use it without...

Kruptein
Posting Whiz in Training
258 posts since Sep 2009
Reputation Points: 25
Solved Threads: 11
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You