mail()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
elecktricity
Forum Contributor
Posts: 128
Joined: Sun Sep 25, 2005 8:57 pm
Location: Trapped in my own little world.
Contact:

mail()

Post by elecktricity »

im trying to get a register page where when you register it puts a random 36 digit code in a database, then it emails you this code so that you can activate an account and all that fun stuff... but for some reason the mail function isnt working

Code: Select all

<?PHP
$to = 'blayne4k@gmail.com';
$subject = 'testing';
$message = 'just seeing if this works';
if (mail($to,$subject,$message, "From: blayne4k@gmail.com")){
	echo "Mail sent successfully to $to.";
	}
else{
     echo "Email Didnt Send";
}
?>
its giving me the success message "mail sent successfully to blayne4k@gmail.com" but im not receiving the message, i tried other email addresses as well and tried taking out the header information, it just wont work

EDIT: I thought it may be helpful to post the PHP Version which is 4.4.1
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

If this is on a home machine, you may have to point your SMTP server to the right place in the php.ini file.
User avatar
elecktricity
Forum Contributor
Posts: 128
Joined: Sun Sep 25, 2005 8:57 pm
Location: Trapped in my own little world.
Contact:

Post by elecktricity »

no its on my host, it worked the first time I tried it before adding headers, and it just didnt work after that
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

it's possible that your smtp server won't accept mails "from" a different address.

you might need to authenticate to your smtp server to allow that "feature".
User avatar
elecktricity
Forum Contributor
Posts: 128
Joined: Sun Sep 25, 2005 8:57 pm
Location: Trapped in my own little world.
Contact:

Post by elecktricity »

hmm ill ask the hosting dude if he knows whats up, thanks for the help all
Post Reply