/    Sign up×
Community /Pin to ProfileBookmark

Contact Form / Php Not Sending Email

Hi Everyone,

I’m trying to send data from a contact form to an email address on yahoo. I placed in the below PHP, but the recipient is not receiving any email from the server. My developer’s asleep and I’m at a loss as to why this isn’t working. If someone could look over the below code, maybe you see something I may have missed?

Cheers,
Tricky

[code=php]
<?php

function cleanupName($string, $length = 50)
{
$string = stripslashes($string);
$string = preg_replace(“/[^a-zA-Z0-9.-]/”, “”, $string);
$string = substr($string, 0, $length);
return $string;
}

function cleanupPhone($string, $length = 20)
{
$string = stripslashes($string);
$string = preg_replace(“/[^()-0-9]/”, “”, $string);
$string = substr($string, 0, $length);
return $string;
}

function cleanupEMail($string, $length = 50)
{
$string = stripslashes($string);
$string = preg_replace(“/[, :;<>]/”, “”, $string);
$string = substr($string, 0, $length);
return $string;
}

function cleanupComment($string, $length = 500)
{
$string = stripslashes($string);
$string = preg_replace(“/[<>:;]/”, “”, $string);
$string = substr($string, 0, $length);
return $string;
}

if (isset($_POST[‘name’])) $name = cleanupName(urldecode($_POST[‘name’]));
if (isset($_POST[‘company’])) $company = cleanupName(urldecode($_POST[‘company’]));
if (isset($_POST[‘phone’])) $phone = cleanupPhone(urldecode($_POST[‘phone’]));
if (isset($_POST[’email’])) $email = cleanupEMail(urldecode($_POST[’email’]));
if (isset($_POST[‘comment’])) $comment = cleanupComment(urldecode($_POST[‘comment’]));

$recipientAddress =
[email protected]”;

$subject =
“Re: Web Site Contact Request”;

$body =
“Name: ” . $name . “rn” .
“Company: ” . $company . “rn” .
“Phone: ” . $phone . “rn” .
“E-Mail: ” . $email . “rn” .
“Comment: ” . $comment;

$headers =
“From: Tricky Fingers <[email protected]>”;

mail($recipientAddress, $subject, $body, $headers);

?>
[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@donatelloSep 25.2008 — Hi Everyone,

I'm trying to send data from a contact form to an email address on yahoo. I placed in the below PHP, but the recipient is not receiving any email from the server. My developer's asleep and I'm at a loss as to why this isn't working. If someone could look over the below code, maybe you see something I may have missed?


Cheers,

Tricky


[code=php]
<?php

function cleanupName($string, $length = 50)
{
$string = stripslashes($string);
$string = preg_replace("/[^a-zA-Z0-9.-]/", "", $string);
$string = substr($string, 0, $length);
return $string;
}

function cleanupPhone($string, $length = 20)
{
$string = stripslashes($string);
$string = preg_replace("/[^()-0-9]/", "", $string);
$string = substr($string, 0, $length);
return $string;
}

function cleanupEMail($string, $length = 50)
{
$string = stripslashes($string);
$string = preg_replace("/[, :;<>]/", "", $string);
$string = substr($string, 0, $length);
return $string;
}

function cleanupComment($string, $length = 500)
{
$string = stripslashes($string);
$string = preg_replace("/[<>:;]/", "", $string);
$string = substr($string, 0, $length);
return $string;
}

if (isset($_POST['name'])) $name = cleanupName(urldecode($_POST['name']));
if (isset($_POST['company'])) $company = cleanupName(urldecode($_POST['company']));
if (isset($_POST['phone'])) $phone = cleanupPhone(urldecode($_POST['phone']));
if (isset($_POST['email'])) $email = cleanupEMail(urldecode($_POST['email']));
if (isset($_POST['comment'])) $comment = cleanupComment(urldecode($_POST['comment']));

$recipientAddress =
"[email protected]";

$subject =
"Re: Web Site Contact Request";

$body =
"Name: " . $name . "rn" .
"Company: " . $company . "rn" .
"Phone: " . $phone . "rn" .
"E-Mail: " . $email . "rn" .
"Comment: " . $comment;

$headers =
"From: Tricky Fingers <[email protected]>";

mail($recipientAddress, $subject, $body, $headers);

?>
[/code]
[/QUOTE]



I'm not good enough at PHP to troubleshoot your script, but there is an easier one you can use that works for me. I got it here:

http://www.tectite.com/

The form is on an HTML page, but it 'bounces' the form off of a hidden page which contains the PHP script. They have a generator on the page I gave you the link to above that will generate the two files for you.

It so easy, even I was able to do it!

Here it is in action on my page, and yes it works!

file:///C:/Documents%20and%20Settings/ddelpercio/Desktop/websites/howtofindsomeoneonline/contact.html

Good luck!
×

Success!

Help @TrickyFingers spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...