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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mail function ih PHP 1

Status
Not open for further replies.

cschaffer

IS-IT--Management
Aug 21, 2001
196
CA
Helllo I am very new to php, but I understand there is a mail function, whith is faily straight forward...I am running an Apache web server on a NT platform...the site works fine but the mail function...none of the pages that need to use this function work...I have put the "smtp=" in the php.ini but still get an error...I run my own web/email server (receiving and sending) and both work other then my prob....any comments/suggestions greatly appreciated!!!
CS
 

$message = "blah blah";
$message .= "Your account information is as follows:\n";
$message .= "----------------------------\n";
$message .= "Username: $username\n";
$message .= "Password: $password\n";
$message .="\blah blah.";
$message .= " However, should you forget your password we provide an easy to use script to generate and email a new, random, password.\nThank you for registering.";
$message .= "\r\n$email_sig";

mail($email, $l_welcomesubj, $l_welcomemail, "From: $email_from");
 
Your variable names changed when you got to the mail() function but I'm guessing that's just in this example. You can set that function to a variable to test if the email was submitted to the local mail system, too.

$gotSent = mail($email, $l_welcomesubj, $l_welcomemail, "From: $email_from");

It will equal 0 if it didn't get processed by PHP correctly. Of course, you have no way of checking if the email got delivered using PHP, you'd have to check the server for that.

Have you tried putting this right before the mail() part, for checking?

echo &quot;<p>&quot; . $email;
echo &quot;<p>&quot; . $l_welcomesubj;
echo &quot;<p>&quot; . $l_welcomemail;
echo &quot;<p>&quot; . $email_from;
exit();

Your mail may have issues if $email or $email_from aren't valid email addresses.

If that all checks out I'd start making sure that the server is cooperating. Also, can you send an email like this?

mail(&quot;yourname@yourdomain.com&quot;,&quot;Testing&quot;,&quot;Test email&quot;);

Something really simple, no variables or anything. Can anyone else add some troubleshooting for the server part of this? I'm a programmer, Jim, not a Sys Admin!
 
I will try your suggestions.....once again thanks...I will let you know how it goes......
 
Warning: Unknown error in c:\blah\blah\blah.php on line 28
******************************************************
this is the error I get when adding the &quot;test&quot; email
mail(&quot;blah@blah.com&quot;,&quot;Testing&quot;,&quot;Test email&quot;);
this is the same error message I get when using the mail function......
******************************************************
Thanks
 
Change the &quot;blah@blah.com&quot; to your real email address. Your server mail is rejecting it because it's a fake email address. Make it send the test messages to your actual email or it definitely won't work.
 
I tried a couple of real email addresses same prob????
Thanks
 
Just so you know...I did add the test to view the variables and they are holding the correct informatation......
 
What about those other checks, did they pass? What did $gotSent equal? When you echoed the values did they look okay? You know, it's possible the mail is getting delivered but it's really delayed. I'm sure you've had mail show up a day late, sometimes that happens.

You may need some input from someone else who knows more about the configuration of PHP. There must be some &quot;undelivr&quot; folder that holds all undeliverable email. I'd check there, or see if the spool is full but not working. Sorry I don't know the specifics about this end of it, knowledge doesn't extend to that area for me.
 
k the thing is..I get that error message..otherwise I would accect the fact that it could be delayed.....Thanks for your help...beleive it or not I learned a lot even though we never really solved the prob!!

Thanks

CS
 
Sorry I couldn't help all the way through this -- maybe you need a new post asking for some mail server help? Your PHP looks good to me. You might also want to search by your specific error message on PHPBuilder.com or even just in a regular search engine.

Let me know how it turns out!
 
What does the '@' symbol do in PHP...I read somewhere that this will solve the error in some cases...it did...but is it really solving the problem or just getting rid of the error...thanks

CS
 
It's supressing the error -- so whether or not there actually is an error it'll just keep on processing rather than exiting and outputting the error message. Handy if you want to handle the error your own way.

Hey if you want a little link to a PHP lookup thing I wrote, feel free to use -- it just makes looking up stuff a little easier on PHPBuilder.com (I think there are too many clicks on that site to find what you want). Or just make the page on your own server (here's the whole page).

<html>
<head>
<title>Search PHPBuilder.com</title>
</head>

<body>

<script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;>
<!--
var str = prompt(&quot;Search PHPBuilder.com for the following string\nor click Cancel to enter a function name:\n &quot;,&quot;&quot;);
if (str != null)
window.location.href = &quot; + str;
else {
str = prompt(&quot;Go directly to the PHPBuilder.com page for the following function:\n&quot;,&quot;&quot;);
if (str != null)
window.location.href = &quot; + str + &quot;.php&quot;;
else
document.write(&quot;Reload this page to try again.&quot;);
}
//-->
</script>

</body>
</html>

Enjoy!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top