By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,976 Members | 1,162 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,976 IT Pros & Developers. It's quick & easy.

mail() returns false but mail is sent

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.