Any help is appreciated - Contact form PHP

Hi, I’m trying to code my clients contact form using PHP. I’ve little/ no PHP experience so would really appreciate the help. I think it’s related to the ‘mail’ in the following line of code:

$success = mail($webMaster, $emailSubject, $body, $headers);

When i use the form on the live website i’m given the following error:

Warning: mail() [function.mail]: SMTP server response: 550 [email protected] No such user here in C:\Inetpub\vhosts\amoraebridal.co.uk\httpdocs\contact_form.php on line 25

I’d really appreciate some help from you guys if you have the time, Ive been at this a couple of days now and I’m not getting anywhere. Thanks for your time and help!! See my entire PHP code below:

<?php /*subject and email variables*/ $emailSubject = 'Amorae Bridal Contact Form'; $webMaster = '[email protected]'; /*gathering data variables*/ $nameField = $_POST['name']; $phoneField = $_POST['phone']; $dateField = $_POST['date']; $commentField = $_POST['comment']; $body = <<<EOD


Name: $nameField
Phone Number: $phoneField
Wedding Date: $dateField
Comments: $commentField
EOD; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /*Results render in HTML*/ $theResults = <<<EOD Untitled Document Please work this time... EOD; echo "$theResults"; ?>

Well, I do not see any “TO:” in your email. You have to send the email to someone.
I am assuming that maybe the “Webmaster” was supposed to be the “TO:”, but, in the email code, you did not assign an email address to send the message to.

If that does not fix it, please repost your code. Please put it INSIDE the PHP button above. This way we can “SELECT” it and it is easier for us to use your code for testing…

Good luck…

Thanks for your reply!!

I’ve tried “TO:” and got a syntax error so tried “TO” and got the same error as before. The "webMaster works to one of my e-mail accounts but i get the error with the clients, my gmail and my hotmail.

The line " $webMaster = ‘[email protected]’; " is the line that references the e-mail that it’s going to.

[php]<?php

/subject and email variables/

$emailSubject = 'Amorae Bridal Contact Form';
$webMaster = '[email protected]';

/gathering data variables/

$nameField = $_POST['name'];
$phoneField = $_POST['phone'];
$dateField = $_POST['date'];
$commentField = $_POST['comment'];

$body = <<<EOD





Name: $nameField

Phone Number: $phoneField

Wedding Date: $dateField

Comments: $commentField

EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);

/Results render in HTML/

$theResults = <<<EOD
Untitled Document Please work this time... EOD; echo "$theResults"; ?>[/php]

Thanks again for your help but sadly it’s still not working :frowning:

Sorry, yes, your “webmaster” was correct. I read your code incorrectly!

Here is a small sample of how to do an email, the smallest I had.
It works with my info stuck in it.
I compared it to your code and noticed one problem. Hope it is the solution for you…
On your code:
$headers = “From: $email\r\n”;
This should be something like:
$headers = "From: " . $email . “\r\n”;
You are not passing a “FROM” address so the email would be dumped.
Let us know if that solves it…
[php]

<?php $to = '[email protected]'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?>

[/php]

I’ve tried that and it’s still not working. still square 1 for me, thanks though!

repost your current code so we can see where you stand now… Thanks…

The problem is that it works with my e-mails address but not the clients email.domain address, I’m thinking now that it’s related to the SMTP issue in the error im getting. (Warning: mail() [function.mail]: SMTP server response: 550 [email protected] No such user here in C:\Inetpub\vhosts\amoraebridal.co.uk\httpdocs\contact_form.php on line 24

My current code is: [php]

<?php /*subject and email variables*/ $to = '[email protected]'; $subject = 'the subject'; /*gathering data variables*/ $name = $_POST['name']; $phone = $_POST['phone']; $date = $_POST['date']; $comment = $_POST['comment']; $body = <<<EOD


Name: $name
Phone Number: $phone
Wedding Date: $date
Comments: $comment
EOD; $headers = "From: Amorae Contact Form\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($to, $subject, $body, $headers); /*Results render in HTML*/ $theResults = <<<EOD Untitled Document Please work this time... EOD; echo "$theResults"; ?>

[/php]

LOL! Well, not sure if mailing out from the localhost will work if it is out of your domain.
It depends if you set up a SMTP in your server. Here is one post that I found that talks about it.

http://roshanbh.com.np/2007/12/sending-e-mail-from-localhost-in-php-in-windows-environment.html

One other thing, your results of the mail call will not display unless you remove the quotes around it.
Make:
echo “$theResults”;

This:
echo $theResults;

maybe that is just the problem. This code does work on my testing. But, that is a online server…
Let me know…

Sponsor our Newsletter | Privacy Policy | Terms of Service