Page 1 of 1

mail()

Posted: Sun Nov 27, 2005 1:51 pm
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

Posted: Sun Nov 27, 2005 4:27 pm
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.

Posted: Sun Nov 27, 2005 4:42 pm
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

Posted: Sun Nov 27, 2005 4:48 pm
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".

Posted: Sun Nov 27, 2005 5:21 pm
by elecktricity
hmm ill ask the hosting dude if he knows whats up, thanks for the help all