Page 1 of 1
php mail() not working !!!!!!
Posted: Mon Aug 03, 2009 4:34 am
by ram.mahaseth
Hello there,
I've been trying to use mail function to email but it is not working when i call it from script.It parses without error and displays phpinfo() page.But I couldnot see any email in my inbox.
This is my php code to email.
Code: Select all
<?php
mail('ram.mahaseth@gmail.com','testingfrom php','hello');
phpinfo();
?>
It delivers email when I call it from terminal by
[root@localhost usr]# /usr/sbin/sendmail.postfix -t < test.txt
Where test.txt contains,
From:
ramkr75_4@yahoo.com
To:
ram.mahaseth@gmail.com
Subject: Test message
<h1>This is a test message from terminal using postfix</h1>
I have installed xampp server on my Redhat5 also using postfix as my mail server.
Please help me out here.
Re: php mail() not working !!!!!!
Posted: Mon Aug 03, 2009 8:04 am
by jackpf
Have you got error reporing turned up to full? (as in, E_ALL or E_STRICT)
Re: php mail() not working !!!!!!
Posted: Mon Aug 03, 2009 8:31 am
by Eric!
Are you sending it from a site hosted on Yahoo.com? If not, gmail (or even your host server) might be deleting it because the header looks forged. The from header might not be correct in the .ini file...honestly I'm not sure where it gets the $from field if is isn't specified.
Try putting in a little header information with the correct domain of your site where it is hosted.
Code: Select all
<?php
$to = 'nobody@gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: you@yourdomain.com' . "\r\n" .
'Reply-To: you@yourdomain.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
Re: php mail() not working !!!!!!
Posted: Mon Aug 03, 2009 9:50 am
by ram.mahaseth
this is the entry from my php.ini file
Code: Select all
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
;sendmail_from = me@localhost.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/sbin/sendmail.postfix -t -i
sendmail_from = ram.mahaseth@gmail.com
the email is valid email since its my own email id.
i even tried ur php script but it is not working...
waiting for th reply
Re: php mail() not working !!!!!!
Posted: Mon Aug 03, 2009 10:36 am
by Eric!
Where are you running the script when it is not working? Is the .ini file you posted from the non working server or your local server where you are testing it?
Did you enable the error messages like Jackpf suggested? Does the server have SMPT installed?
Re: php mail() not working !!!!!!
Posted: Mon Aug 03, 2009 11:32 pm
by ram.mahaseth
my php script is in
/opt/lampp/htdocs/
folder.
my ini file is in local server in
/opt/lampp/etc/
folder.
No i didn't enabled error messages.
How should i check whether SMTP is installed or not?
It works when i send mail from terminal.
Code: Select all
[root@localhost usr]# /usr/sbin/sendmail.postfix -t < test.txt
Re: php mail() not working !!!!!!
Posted: Tue Aug 04, 2009 6:54 am
by jackpf
Well "enable errors" and you'll find out won't you.