Link to home
Start Free TrialLog in
Avatar of wood1e
wood1e

asked on

USing a standard email form PHP

Hi I have just tried an email form tutorial, and I get these errors

I am running advanced SMTP server as well as Apavhe 2

Notice: Undefined index: email in C:\Program Files\Apache Group\Apache2\htdocs\sendmail.php on line 2

Notice: Undefined index: message in C:\Program Files\Apache Group\Apache2\htdocs\sendmail.php on line 3

Warning: mail(): SMTP server response: 550 Invalid recipient: info@synaxisolutions.co.uk in C:\Program Files\Apache Group\Apache2\htdocs\sendmail.php on line 6

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\sendmail.php:2) in C:\Program Files\Apache Group\Apache2\htdocs\sendmail.php on line 7

Can obviously add code for email form...
Avatar of Timothy Golden
Timothy Golden
Flag of United States of America image

post the code
Avatar of Tagor
Tagor

"Warning: mail(): SMTP server response: 550 Invalid recipient: info@synaxisolutions.co.uk in C:\Program Files\Apache Group\Apache2\htdocs\sendmail.php on line 6"

Something is wrong with your SMTP server. I am not sure what SMTP software you are using. You could also change the SMTP server in the php.ini file. Note that you will need to restart apache after modifing the php.ini file.
Avatar of wood1e

ASKER

The HTML is

<form id="myform">

     <fieldset>
     <legend>Contact form</legend>

     <label for="enquiryname"><span>Name: <strong class="red_text">*</strong></span></label>
        <input type="text" name="enquiryname" id="enquiryname" value="" size="32" /><br />

        <label for="enquiryemail"><span>Email Address: <strong class="red_text">*</strong></span></label>
     <input type="text" name="enquiryemail" id="enquiryemail" value="" size="32" /><br />

     <label for="enquirytelephone"><span>Telephone:</span></label>
     <input type="text" name="enquirytelephone" id="enquirytelephone" value="" size="32" /><br />

     <label for="enquiryaddress1"><span><strong>Address Line 1:</strong> <strong class="red_text">*</strong></span></label>
     <input type="text" name="enquiryaddress1" id="enquiryaddress1" size="32" value="" /><br />

     <label for="enquiryaddress2"><span>Address Line 2:</span></label>
     <input type="text" name="enquiryaddress2" id="enquiryaddress2" size="32" /><br />

     <label for="enquirytown"><span>Town: <strong class="red_text">*</strong></span></label>
     <input type="text" name="enquirytown" id="enquirytown" size="32" /><br />

     <label for="enquirypostcode"><span>Postcode: <strong class="red_text">*</strong></span></label>
     <input type="text" name="enquirypostcode" id="enquirypostcode" value="" size="8" /><br />

     <label for="enquirycomments" class="textarea"><span>Comments or questions <strong class="red_text">*</strong></span></label>
        <textarea name="enquirycomments" id="enquirycomments" cols="50" rows="10"></textarea><br />

     <label for="enquirynewsletter" class="right"><span><input type="checkbox" name="enquirynewsletter" id="enquirynewsletter" value="checkbox" /></span></label>
     <div class="comment">Tick if you wish to receive David Mundell's email newsletters</div></p>

     <label style="border:none;"><span></span></label>
     <input class="button" type="submit" value="Send" name="submit" class="submit" />

        </fieldset>

</form>


and the PHP is

<?
      $email=$_REQUEST['email'];
      $message=$_REQUEST['message'];

      mail("info@synaxisolutions.co.uk", "Feedback form results",
      $message, "Form:$email");
      header ("Location: http://www.example.com/thankyou.htm");
?>

I am sure I found it on this website, but with me playing around with it I think I have really buggered it up!!!.....Thats a technical term :)

I am using Advanced SMTP...
Avatar of wood1e

ASKER

ANd this is from my PHP.ini file...

[mail function]
; For Win32 only.
SMTP = localhost ; for Win32 only
smtp_port = 25
sendmail_from= info@synaxissolutions.co.uk ; for Win32 only

; For Win32 only.
;sendmail_from = info@syanxissolutions.co.uk

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
I take it you have a Windows Server. Using what SMTP server? Sounds like relaying isn't properly setup to me.
Avatar of wood1e

ASKER

I am using, Apache, and Advanced SMTP on win2k pro machine
You might need to set up your 'trusted senders' in the Advanced SMTP program.

JP
Avatar of wood1e

ASKER

HI, I donp;t appear to need as I tested Port 25 and it worked?
Avatar of wood1e

ASKER

HI,

I have changed the scrips I am using..and I have found a simple email form using PHP...

The HTML is :

Send us an comment about our site!<br />
<form action="mail.php" method="post">
Subject for email : <input type="text" name="subject"><br />
Visitor email : <input type="text" name="from"><br />
Message : <textarea name="message" rows="3" cols="40"></textarea><br />
<input type="submit" value="Send the info">
<input type="reset" value="Clear the form">
</form>

Saved in my htdocs folder

ANd the PHP is:

<?php
$to = "info@synaxissolutions.co.uk";

$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: " . $from . "\r\n";
$headers .= "Return-Path: " . $from . "\r\n";

if ( mail($to,$subject,$message,$headers) ) {
   echo "The email has been sent!";
   } else {
   echo "The email has failed!";
   }
?>

Also saved in my htdocs folder...

When I click send/submit button I get a window saying do I want to downlaod or save...

WHat is wrong? please help...:)
Sounds like you don't have PHP properly set up any more. What else have you changed?
Avatar of wood1e

ASKER

NOthing as far as I know...

WHat else do I need to look at?
Avatar of wood1e

ASKER

PS I can post my.ini if required...

Oh and when I usemy browser to view info.php it works..and I have all the php info?
"do I want to download or save"...

what file type does Windows think you are downloading?

try to use telnet to fetch the file, and send us the headers which your server is sending across.

The command is something like

telnet www.yourserver.com 80

The you have to hand-type

HTTP/1.0 GET /

It's something like that... you'll have to look it up on the web.

JP
>When I click send/submit button I get a window saying do I want to downlaod or save...

This is a mime-type handler problem. PHP isn't properly setup in apache.

Regarding : synaxisolutions.co.uk
root@trisha [/usr/local/lib]# dig synaxisolutions.co.uk

; <<>> DiG 9.2.4 <<>> synaxisolutions.co.uk
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 11309
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

root@trisha [/usr/local/lib]# dig mx synaxisolutions.co.uk

; <<>> DiG 9.2.4 <<>> mx synaxisolutions.co.uk
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 46994
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0


Could you get getting a 550 because it can't find the domain? Looks like your dns is not properly setup.

More than likely though, your email server has given you a 550 since relaying is denied. Properly setup you email server, and this won't occur.
Please attempt immediately to email 'mcollard@hotmail.com' and see if it gives you the error. I think the DNS MX entry is giving you the trouble.

PS: If I fix the problem, I want points from all the questions. =) J/K
According to my research this 550 Invalid recipient could happen if the domain MX, but not the user was found. But because I can't find your MX, I assume your SMTP can't either. =)
Avatar of wood1e

ASKER

Hi Promethyl,

Do you mean set up a send email form with your address as the receiving address?
Just about any address besides synax*.com. I want to see if that's the problem. Any problem which we can narrow down as NOT RELATED is one more step which brings you to your successful conclusion.
 
Avatar of wood1e

ASKER

oh right, ok I have created anew form and email .php from another tutorial and they seem to work...I have posted the .php file and .htm file, below....

Can't see why this should work!!!!????!!!!
Even more confused now :)

mail.htm

<html>
<head><title>fgf</title>
</head>

<body>

<form action="mail.php" method="post">
Your Name: <input type="text" name="name"><br>
E-mail: <input type="text" name = "email"><br><br>
Comments<br>
<textarea name="comments"></textarea><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>



mail.php

<?
$name=$_POST['name'];
$email=$_POST['email'];
$comments=$_POST['comments'];
$to="info@synaxissolutions.co.uk";
$message="$name just filled in your comments form. They said:\n$comments\n\nTheir e-mail address was: $email";
if(mail($to,"Comments From Your Site",$message,"From: $email\n")) {
echo "Thanks for your comments.";
} else {
echo "There was a problem sending the mail. Please check that you filled in the form correctly.";
}
?>


both these fiels are saved to the htdocs folder

PS you can have as many points as I can offer if you can explain what the hell is going on...why the above works?
Well, you dropped the headers for one. Remove the headers in the first program and see if it works...

Perhaps a spam blocker nailing you because it doesn't like one of the header fields?
Avatar of wood1e

ASKER

I will look at it again tomorrow..and try a more sophisticated form email...and see what happens...then if the more sophisticated one works i will award points, many thanks for sticking around...tired now so off to bed..

Something I did notice...if I open up htdocs folder, and double clicked on the .htm file, and then filled out fetails adn clicked send...a window would show asking whether I wanted to save or download...

BUt if I typed into my browser localhost/mail.htm  no problem at all....filled out detais sent form, and got it in my Outlook!!  Very strange indeed...but something else learnt...which has to be good...

Once again many thanks...
ASKER CERTIFIED SOLUTION
Avatar of Promethyl
Promethyl
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wood1e

ASKER

Hi, Sorry for the delay, I have been busy living!!! :)

ANyway I found a form from formtoemail.com  which I have just tested, and it works as well as an even simplier form mail I tried the other day..

Now just need to woork at it, so I can get rid of their link, and hide the receinving email address...

Many thanks for your help...

Rob (wood1e)