Page 1 of 2

PHP Email Problems

Posted: Fri Oct 06, 2006 2:07 pm
by phpunleashed
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]


This is probably a really stupid question that should be answered easily.  I have been scouring Tutorials and How Tos for days now and have been reluctant to submit a new post it in any forums for fear of someone having a one sentence answer, then continuing on for pages on how they pwned me and i'm such a noob.

Anyways here goes.  I have created an online form for an application and the form works fine, it has a subsequent page that shows what information they have entered and it stores it all into a database quite nicely.  My problem is that it will not email.

Here is some of the relevant code for the email:

Code: Select all

$message = stripslashes($message);
$mail_path = "/usr/sbin/sendmail -t" ;

mail("info@example.com","Application Form .$firstname. .$lastname.",$message,"From: $email");
$to_put .= $FirstName."|".$LastName."|".$MiddleI."|".$Address."|".$Suite."|".$City."|".$State."|".$ZipCode."|".$Email";
Database is working fine, but I thought I would include it for kicks:

Code: Select all

$make=fopen("admin/data.dat","a");
$to_put="";
$to_put .= $FirstName."|".$LastName."|".$MiddleI."|".$Address."|".$Suite."|".$City."|".$State."|".$ZipCode."|".$Email";
fwrite($make,$to_put);
Let me know what information you need to diagnose the problem.
Thanks


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]

Re: PHP Email Problems

Posted: Fri Oct 06, 2006 2:46 pm
by RobertGonzalez
Not much of a change, but try this.

Code: Select all

<?php
$message = stripslashes($message);

// Is this used anywhere?
$mail_path = "/usr/sbin/sendmail -t" ;

// try some error checking
if (!mail('info@example.com', 'Application Form ' . $firstname . ' ' . $lastname, $message, 'From: ' . $email))
{
    echo 'Could not send the mail';
}
?>

Could not send the mail

Posted: Fri Oct 06, 2006 2:57 pm
by phpunleashed
I put in the error checking you suggested and it came up. Am I not calling my sendmail correctly? I am very new to PHP so I am probably missing something really obvious.

Posted: Fri Oct 06, 2006 3:08 pm
by RobertGonzalez
According to the PHP manual on mail():
Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.

It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.
What that means is that you mail server is not accepting the mail for delivery.

Posted: Fri Oct 06, 2006 3:20 pm
by phpunleashed
is there an easy way to do that? Get my mail server to accept it? I am looking into it.
Thanks for the fast help.

Posted: Fri Oct 06, 2006 4:06 pm
by Chris Corbyn
Have you got sendmail installed on the server?

Posted: Fri Oct 06, 2006 4:16 pm
by phpunleashed
yes, sendmail is installed

Posted: Fri Oct 06, 2006 4:17 pm
by RobertGonzalez
Also, is this a local server or a hosted server?

Posted: Fri Oct 06, 2006 4:17 pm
by Burrito
send mail through any other application from that server can you?

Posted: Fri Oct 06, 2006 4:24 pm
by phpunleashed
It is a hosted server, and sendmail is working great for everything else.

Posted: Fri Oct 06, 2006 4:25 pm
by RobertGonzalez
Run a simple test hard coding the params into the function along with an error trap. See if that does anything. I doubt it will, but for problem solving purposes, start simple and work outward.

Posted: Fri Oct 06, 2006 5:02 pm
by phpunleashed
Thanks for all the help, btw i posted that incorrectly that my server was hosted... it's really local. My weekend starts now so i'll be back monday stewing over it. If you have any other ideas come over the weekend these posts are helping me get closer to the problem.
Thanks

Posted: Fri Oct 06, 2006 7:46 pm
by RobertGonzalez
If it is a local server I would guess that sendmail is not installed/configured. You may want to check that first before trying anything else code-wise.

Posted: Mon Oct 09, 2006 10:38 am
by phpunleashed
These are the errors I am getting in my sendmail logs:

Code: Select all

Oct  9 09:36:20 chief02 sendmail[30279]: k99FaKmp030279: from=apache, size=1120, class=0, nrcpts=1, relay=apache@localhost
Oct  9 09:36:20 chief02 sendmail[30279]: k99FaKmp030279:   0: fl=0x0, mode=10600: FIFO: dev=0/5, ino=23777300, nlink=1, u/gid=48/48, size=0
Oct  9 09:36:20 chief02 sendmail[30279]: k99FaKmp030279:   1: fl=0x1, mode=20666: CHR: dev=0/13, ino=1869, nlink=1, u/gid=0/0, size=0
Oct  9 09:36:20 chief02 sendmail[30279]: k99FaKmp030279:   2: fl=0x2, mode=20666: CHR: dev=0/12, ino=174, nlink=1, u/gid=0/0, size=0
Oct  9 09:36:20 chief02 sendmail[30279]: k99FaKmp030279:   3: fl=0x2, mode=140777: SOCK localhost->[[UNIX: /dev/log]]
Oct  9 09:36:20 chief02 sendmail[30279]: k99FaKmp030279:   4: fl=0x1, mode=20666: CHR: dev=0/13, ino=1869, nlink=1, u/gid=0/0, size=0
Oct  9 09:36:20 chief02 sendmail[30279]: k99FaKmp030279: SYSERR(apache): queueup: cannot create queue file ./qfk99FaKmp030279, euid=48, fd=-1, fp=0x0: Permission denied
~

Posted: Mon Oct 09, 2006 1:17 pm
by phpunleashed
Does anyone know where i could configure the php form to use a different address instead of apache@localhost or to how to allow apache@localhost permission?
Thanks