View Full Version : mail() function doesn't work
groog
07-08-2008, 01:58 AM
I have no other scripts running on the page I set up just to test it. My code is simply-
<?php
mail('fruzzgle@gmail.com', 'test', 'test');
?>
And when I visit the page I get no email o.O
Why doesn't this work?
Fou-Lu
07-08-2008, 02:03 AM
Is this on a live server or on a testing environment?
If its live, there may be additional things required by your host to interact with an smtp server. If its on your local machine, you need to ensure that smtp daemons/services are running correctly. Generally you include other headers as well (from, mimes, etc), but best I know they are not actually a requirement to use PHP mail. In other words, there is nothing incorrect with your mail usage.
groog
07-08-2008, 02:10 AM
This isn't on my machine. I'm using myhosting247.com
Fou-Lu
07-08-2008, 02:19 AM
You'll need to contact your hosting company than.
mail does return a boolean result, to my understanding that indicates if the mail was queued correctly for delivery. You can check with server logs or enable error_reporing as well, its possible that mail has been disabled as a function that can be used, which wouldn't really surprise me considering that they have safe_mode enabled (unless you are on a paid plan).
Yes, I should have mentioned this in the first post but thats ok. Mail uses four directives for its configurations:
SMTP
smtp_port
sendmail_from
sendmail_path
If any of these are incorrect, than the mail function will fail to work. Error reporting will detect if these are wrong and at least point you in the correct location, specifically the sendmail_path is most important.
I lied, SMTP and smtp_port are only used with windows environments, so are not required for sendmail on *nix.
barkermn01
07-08-2008, 11:54 AM
if you have a problem using php mail might be a shared host that dosent allow it my server dose it just install php mailer and use that it mutch better can use any servers you want
_Aerospace_Eng_
07-08-2008, 05:13 PM
Its very possible that your host doesn't allow mail to be sent with them if you are using their free hosting.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.