Page 1 of 1

php mail()

Posted: Mon Nov 20, 2006 11:19 am
by tuckhx
Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi,

I am trying to write a simple form in php that when submitted sends an email to a user.

I have looked that the php.net mannual and I am using the mail() function.

I am writing this on an linux machine and I can send mail from that server. SMTP or sendmail is working.

But when I code this and execute it from a browser I get an Error and mail is not send. 

Can someone please tell me 

1. Is everything set up correctly?

2. Is there any additional logging to debug this?

3. IS there a additional function to output the error? 

My google did not turn up anything helpful to me. it sound simple and straight forward.

Below is the test code I use

Code: Select all

<?php

if(mail('send@myphpserver.com', 'Test subject', 'Test Body', 'from@myphpserver.com')){
       echo("<p>sent</p>");
} else {
       echo("<p>FAILED</p>");
}

?>

Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Nov 20, 2006 11:25 am
by RobertGonzalez
Your additional headers may be jacking this thing up. Try this...

Code: Select all

<?php
if (mail('send@myphpserver.com', 'Test subject', 'Test Body', 'From: from@myphpserver.com') {
    echo '<p>sent</p>';
} else {
    echo '<p>FAILED</p>';
}
?>