Hey, im trying to use the mail() function, but its not working. This is the script:

<html>
<head>
</head>
<body>
	<?php
		if(mail("coolgamer48@gmail.com","Test","Test","From:coolgamer48@gmail.com"))
		{
			echo "Success";
		}
		else
		{
			echo "Failure";
		}
	?>
</body>
</html>

I keep getting "Failure". Is there an issue with my syntax, or is it some other problem?

I'm running Ubuntu, and I've done nothing other than installing PHP to use the mail functions.

I think, the fourth is a header, and maybe you stated it wrong. Try to send without headers:

mail("somebody@example.com","My subject",My Bodytext);

And post here the result

Your mail function is perfectly fine. Does it give you any error other than "Failure" ? Umm..have you disabled error reporting ? Have you set sendmail path in php.ini ? usually, /usr/sbin/sendmail is the path for sendmail.

This article has been dead for over six months. Start a new discussion instead.