469,628 Members | 1,231 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

mail and displaying errors

I'm trying to debug someone else's third party code that I'm trying to
install on my site. It works for him on his site, but not for me on
"my" site.

I've traced the problem to the mail() call. For whatever reason, it's
failing. And, my question is - how do I make php print the real
reason for the failure?

I've modified his code (multiple times), so that it now looks like
this:

error_reporting(E_ALL);

$mail_sent = @mail($Email_Address, $subscribe_email_subject,
$subscribe_confirm_msg, "From: $DB_OwnerName < $DB_ReplyToEmail >", "-
f $DB_ReplyToEmail");
if ($mail_sent)
echo "Mail sent";
else
die ("Mail failed" . " in File: " . __FILE__ . " on line: " .
__LINE__ . " Error was:" . $mail_sent[1] );

It tells me the mail failed and in what file and on what line as
expected, but I can't figure out how to make it print the true &
actual error (such as "permission denied" or perhaps "no such file" or
whatever the true error is). Prior to my changes, it simply had the
mail function without the @ and without capturing the return value.

So my question is two-fold:
1) How do I print the actual error and
2) What should I be looking at to figure out why mail is failing to
send? Or to put it another way, what might be the possible reasons
mail is failing that I should be checking?

I'm on a Linux server, but I think he uses Windows to test his code,
though I'm not sure. I'm somewhat new to PHP, but am very computer
and programming literate in C. My goal is not to learn PHP, but just
to get this third party app. working on my web host.

Thank you

May 4 '07 #1
3 1750
Dudely wrote:
I'm trying to debug someone else's third party code that I'm trying to
install on my site. It works for him on his site, but not for me on
"my" site.

I've traced the problem to the mail() call. For whatever reason, it's
failing. And, my question is - how do I make php print the real
reason for the failure?

I've modified his code (multiple times), so that it now looks like
this:

error_reporting(E_ALL);

$mail_sent = @mail($Email_Address, $subscribe_email_subject,
$subscribe_confirm_msg, "From: $DB_OwnerName < $DB_ReplyToEmail >", "-
f $DB_ReplyToEmail");
if ($mail_sent)
echo "Mail sent";
else
die ("Mail failed" . " in File: " . __FILE__ . " on line: " .
__LINE__ . " Error was:" . $mail_sent[1] );

It tells me the mail failed and in what file and on what line as
expected, but I can't figure out how to make it print the true &
actual error (such as "permission denied" or perhaps "no such file" or
whatever the true error is). Prior to my changes, it simply had the
mail function without the @ and without capturing the return value.

So my question is two-fold:
1) How do I print the actual error and
2) What should I be looking at to figure out why mail is failing to
send? Or to put it another way, what might be the possible reasons
mail is failing that I should be checking?

I'm on a Linux server, but I think he uses Windows to test his code,
though I'm not sure. I'm somewhat new to PHP, but am very computer
and programming literate in C. My goal is not to learn PHP, but just
to get this third party app. working on my web host.

Thank you
Do you have an SMTP server (i.e. sendmail) active on your machine, and
is your php.ini pointing at the executable?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 4 '07 #2
On May 4, 3:41 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
Dudely wrote:
I'm trying to debug someone else's third party code that I'm trying to
install on my site. It works for him on his site, but not for me on
"my" site.
I've traced the problem to the mail() call. For whatever reason, it's
failing. And, my question is - how do I make php print the real
reason for the failure?
I've modified his code (multiple times), so that it now looks like
this:
error_reporting(E_ALL);
$mail_sent = @mail($Email_Address, $subscribe_email_subject,
$subscribe_confirm_msg, "From: $DB_OwnerName < $DB_ReplyToEmail >", "-
f $DB_ReplyToEmail");
if ($mail_sent)
echo "Mail sent";
else
die ("Mail failed" . " in File: " . __FILE__ . " on line: " .
__LINE__ . " Error was:" . $mail_sent[1] );
It tells me the mail failed and in what file and on what line as
expected, but I can't figure out how to make it print the true &
actual error (such as "permission denied" or perhaps "no such file" or
whatever the true error is). Prior to my changes, it simply had the
mail function without the @ and without capturing the return value.
So my question is two-fold:
1) How do I print the actual error and
2) What should I be looking at to figure out why mail is failing to
send? Or to put it another way, what might be the possible reasons
mail is failing that I should be checking?
I'm on a Linux server, but I think he uses Windows to test his code,
though I'm not sure. I'm somewhat new to PHP, but am very computer
and programming literate in C. My goal is not to learn PHP, but just
to get this third party app. working on my web host.
Thank you

Do you have an SMTP server (i.e. sendmail) active on your machine, and
is your php.ini pointing at the executable?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -
Does the php.ini file affect all users, or is it set on a per user
basis? If the former, I don't have access. If the latter, should it
live in my home directory or somewhere else? What does/should it look
like (where can I get a sample to plop in)? I don't know if sendmail
runs all the time, but I do have access to the executable. I'm a user
with typical limited access on a web host that is hosting my web page.

Thank you

May 4 '07 #3
Dudely wrote:
On May 4, 3:41 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>Dudely wrote:
>>I'm trying to debug someone else's third party code that I'm trying to
install on my site. It works for him on his site, but not for me on
"my" site.
I've traced the problem to the mail() call. For whatever reason, it's
failing. And, my question is - how do I make php print the real
reason for the failure?
I've modified his code (multiple times), so that it now looks like
this:
error_reporting(E_ALL);
$mail_sent = @mail($Email_Address, $subscribe_email_subject,
$subscribe_confirm_msg, "From: $DB_OwnerName < $DB_ReplyToEmail >", "-
f $DB_ReplyToEmail");
if ($mail_sent)
echo "Mail sent";
else
die ("Mail failed" . " in File: " . __FILE__ . " on line: " .
__LINE__ . " Error was:" . $mail_sent[1] );
It tells me the mail failed and in what file and on what line as
expected, but I can't figure out how to make it print the true &
actual error (such as "permission denied" or perhaps "no such file" or
whatever the true error is). Prior to my changes, it simply had the
mail function without the @ and without capturing the return value.
So my question is two-fold:
1) How do I print the actual error and
2) What should I be looking at to figure out why mail is failing to
send? Or to put it another way, what might be the possible reasons
mail is failing that I should be checking?
I'm on a Linux server, but I think he uses Windows to test his code,
though I'm not sure. I'm somewhat new to PHP, but am very computer
and programming literate in C. My goal is not to learn PHP, but just
to get this third party app. working on my web host.
Thank you
Do you have an SMTP server (i.e. sendmail) active on your machine, and
is your php.ini pointing at the executable?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -

Does the php.ini file affect all users, or is it set on a per user
basis? If the former, I don't have access. If the latter, should it
live in my home directory or somewhere else? What does/should it look
like (where can I get a sample to plop in)? I don't know if sendmail
runs all the time, but I do have access to the executable. I'm a user
with typical limited access on a web host that is hosting my web page.

Thank you
It affects all users. If you're on a hosted system, you need to contact
your hosting company. They may not have an SMTP server set up on this
box, they may restrict it's use to non-web apps, they might require a
login - or any of a dozen other things.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 5 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

16 posts views Thread by SamMan | last post: by
20 posts views Thread by Peter E. Granger | last post: by
6 posts views Thread by Karl Groves | last post: by
2 posts views Thread by Ruud | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.