Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't send email

Status
Not open for further replies.

Chomauk

Programmer
Jun 8, 2001
130
I tried and tried and found a ton of worthless help involving how to set my php.ini file, however, I'm using a web host and cannot change the ini file...can I?

I'm trying to send an email...here's the code:
Code:
<html>
<head><title>PHP Mail Sender</title></head>
<body>
<?php

$to = "me@email.com";
$subject = "TEST!";
$body = "If I ever get this \n\n I'll be one happy guy!";
if (mail($to, $subject, $body))
{
   echo("<p>Message sent!</p>");
}
else
{
   echo("<p>Message delivery failed...</p>");
}
?>
</body>
</html>

I then get "Message sent" but NO mail is delivered. In phpinfo.php my sendmail_path is /usr/sbin/sendmail -t -i and sendmail_from is no value and as far as I know I don't have to change them but of course I could be wrong.

Some of the info I found is pretty straight forward(like above) but doesn't work and others are so convoluted I've given up trying to understand them.

My web host is Apache Web Server if that is even pertinent.

Please help!



"Failure is the tuition you pay for success."
~ Walter Brunell ~
 
First, since this is on a hosted system, have you confirmed with your HSP's administrators that you're the only one having a problem?

Second, is the email address to which you are sending email messages in the same system? ("Same system" meaning "within the HSP's network")



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
First, since this is on a hosted system, have you confirmed with your HSP's administrators that you're the only one having a problem? -- I'll ask them but they're not the best at responding!

Second, is the email address to which you are sending email messages in the same system? ("Same system" meaning "within the HSP's network") -- No. Does is have to be because I sure don't want to be restricted.

I'll re-post if/when they respond to my email.

thanks

"Failure is the tuition you pay for success."
~ Walter Brunell ~
 
Make sure of the first.

As to the second, it's not necessarily a restriction. But if it is a problem with your code, systems tend to be more forgiving of weirdness in intra-system emails. It may be that mail is working, but that a missing or malformed header is causing the foreign (relative to your HSP) mail server to barf on the message. By testing with an in-system mailbox, you may get better info to debug.


Also, have you looked at PHPMailer?



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Suggestion (or ultimate resort):

phpmailer is a class on sourceforge.net which is excellent. It allows for sending mail using a SMTP server. If you can't get it to work with the local sendmail command you have an alternative for delivering messages.
 
Thanks for your help. My web host (Vaticus) didn't and may never have responded to my question so I kept researching and found a great link. It explained it all well enough for me to understand and I got email() to work. Here it is if anyone is interested:

Thanks again...

"Failure is the tuition you pay for success."
~ Walter Brunell ~
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top