469,631 Members | 991 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

mail() returns false but mail is sent

I'm doing a bit of work for a guy and on his system the mail() function
always returns false, but the mail is sent.

Anyone come across this? Any ideas what is causing it and how to fix
it?
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jan 9 '06 #1
6 3463
Geoff Berrow wrote:
I'm doing a bit of work for a guy and on his system the mail() function
always returns false, but the mail is sent.

Anyone come across this? Any ideas what is causing it and how to fix
it?

Sounds like there is a not missing. Got some code to show?
Jan 11 '06 #2
Message-ID: <fD****************@newsread1.news.pas.earthlink.n et> from
Dave Kelly contained the following:
Geoff Berrow wrote:
I'm doing a bit of work for a guy and on his system the mail() function
always returns false, but the mail is sent.

Anyone come across this? Any ideas what is causing it and how to fix
it?

Sounds like there is a not missing. Got some code to show?


Don't think so. My test script is very basic.

<?php
// The message
$message = "Line 1\nLine 2\nLine 3";
// Send
if(mail('bl@*****.co.uk', 'My Subject', $message, 'From:
<bl@*****.co.uk>')){
echo "mail sent";
}

else{
echo "mail not sent";
}
?>

Mail is sent but the screen says mail not sent. Tested on another
server and it works just fine.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jan 11 '06 #3
Geoff Berrow wrote:
Message-ID: <fD****************@newsread1.news.pas.earthlink.n et> from
Dave Kelly contained the following:
Geoff Berrow wrote:
I'm doing a bit of work for a guy and on his system the mail()
function always returns false, but the mail is sent.

Anyone come across this? Any ideas what is causing it and how to
fix it?

Sounds like there is a not missing. Got some code to show?


Don't think so. My test script is very basic.

<?php
// The message
$message = "Line 1\nLine 2\nLine 3";
// Send
if(mail('bl@*****.co.uk', 'My Subject', $message, 'From:
<bl@*****.co.uk>')){
echo "mail sent";
}

else{
echo "mail not sent";
}


Mail is sent but the screen says mail not sent. Tested on another
server and it works just fine.


is the problem server a windows server? Mail is handled slightly different
on a windows server.
Jan 11 '06 #4
Geoff Berrow wrote:
My test script is very basic.

<?php
// The message
$message = "Line 1\nLine 2\nLine 3";
// Send
if(mail('bl@*****.co.uk', 'My Subject', $message, 'From:
<bl@*****.co.uk>')){
echo "mail sent";
}

else{
echo "mail not sent";
}
?>

Mail is sent but the screen says mail not sent. Tested on another
server and it works just fine.


What operating system is the script running on?

What are the mail configuration settings?

Don't copy them from php.ini; run this script instead:
<?php
$opts = array('SMTP', 'smtp_port', 'sendmail_from', 'sendmail_path');
foreach ($opts as $opt) {
echo $opt, ': [', ini_get($opt), "]<br/>\n";
}
?>

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jan 11 '06 #5
Message-ID: <sl*******************@ID-203069.user.individual.net> from
Pedro Graca contained the following:
What operating system is the script running on?
Linux.
What are the mail configuration settings?

Don't copy them from php.ini; run this script instead:
<?php
$opts = array('SMTP', 'smtp_port', 'sendmail_from', 'sendmail_path');
foreach ($opts as $opt) {
echo $opt, ': [', ini_get($opt), "]<br/>\n";
}
?>

Here's what I get:

SMTP: [localhost]
smtp_port: [25]
sendmail_from: []
sendmail_path: [/usr/sbin/sendmail -t -i]

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jan 12 '06 #6
Geoff Berrow wrote:
Message-ID: <sl*******************@ID-203069.user.individual.net> from
Pedro Graca contained the following:
What are the mail configuration settings?


sendmail_path: [/usr/sbin/sendmail -t -i]


Whoooooaa! diving into OT ... :)

Can you have a look at the sendmail logs?
(probably /var/log/mail.err, /var/log/mail.info, and /var/log/mail.log)
What happens if you do

/usr/sbin/sendmail -t -i < mailfile

where mailfile is, for example

---- cut ----
From: "some name" <ch*********@server.invalid>
To: "Geoff Berrow" <ca********@example.com>
Subject: test

test mail
---- cut ----
--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jan 12 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by pee2pee | last post: by
2 posts views Thread by Kindler Chase | last post: by
2 posts views Thread by mike | last post: by
uranuskid
3 posts views Thread by uranuskid | last post: by
5 posts views Thread by Joker7 | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.