php mail function

Dumzaz

Active Member
Joined
Jul 23, 2007
Messages
38
Reaction score
0
Hi

I am using my machine at work as a server running XAMPP. I am also using Mercury for mail. I am trying to implement a simple email feedback form and somehow it says mail successfully sent, but i do not receive anything to my email address specified.

The machine I am working on is on exchange, so I wonder if it would still send email via SMTP. Here is an extract from the php.ini file. Are these OK?


[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
sendmail_from = [email protected]

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"

I am using Windows Vista.
 
And here is the code,
//HTML
<html>
<body>
<form method="post" action="contact.php">
Email: <input name="email" type="text"><br>
Message:<br>
<textarea name="message" rows="15" cols="40">
</textarea><br>
<input type="submit">
</form>
</body>
</html>

----------------------------------------
//PHP
<?php
$to = "[email protected]";
$subject = "Feedback on Knowledge Centre";
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{
print "Your mail was sent successfully";
}
else
{
print "We encountered an error sending your mail";
}
?>
 
In exchange make sure that SMTP relay authentication is turned off. I imagine the Vista machine is running on a domain and logged in at all times? You have to remember though that your app will run on a headless machine under the anonymous user account through apache or IIS. (that serves the pages)

So it might be that the user doesn't have privilages to actually send out the email.

Also, if you're using exchange, I won't use the "localhost" as my server but exchange itself. localhost will just use the vista machine's SMTP rather than exchange's which could mean your email is blocked as spam due to a billion reasons and that's the reason it never gets to your inbox.

Get a proper server, even if it's slow as hell. I'd always recommend LAMP. Nothing better than a native enviroment for this stuff & its for free
 
I agree with AcidRazor. Use a different smtp server you know works, not localhost, and work it back from there.

[edit] Why don't you send it directly to the Mercury server?
 
Last edited:
I agree with AcidRazor. Use a different smtp server you know works, not localhost, and work it back from there.

[edit] Why don't you send it directly to the Mercury server?

If I use mercury, what will be my smtp server name?
Also, is LAMP that much different to XAMPP, I thought they did same thing?
 
If I use mercury, what will be my smtp server name?
Also, is LAMP that much different to XAMPP, I thought they did same thing?

PHP, Apache & MySQL was built for Linux. Running it in it's native enviroment has certain performance benefits as well as the added "I don't have to debug this **** in Windows" you get when trying to set something up to work with M$

The server name for Mercury would be anything you'd like it to be son. You're the programmer ;)
 
Also, have you edited your PHP script to echo your $_REQUEST['email'] etc. fields to make sure that they pull correctly from your form? In your <FORM> tag you've specified to use POST but your using REQUEST? Just a thought... Check to see if you variables pull correctly from your form. Sometimes mail servers won't send a blank e-mail and that might alse be the case...
 
Also, have you edited your PHP script to echo your $_REQUEST['email'] etc. fields to make sure that they pull correctly from your form? In your <FORM> tag you've specified to use POST but your using REQUEST? Just a thought... Check to see if you variables pull correctly from your form. Sometimes mail servers won't send a blank e-mail and that might alse be the case...

I made a couple of mistakes here. I skimped too much on the details. I was using two different sources to learn this and I didn't notice that one was using POST (sending to a diffent ph file) and the other REQUEST (with both the form and php code on the same file). I am going to start again and look at it in more detail.

Thank you all for your input.
 
Top
Sign up to the MyBroadband newsletter
X