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

Have you set up the SMTP setings in the PHP settings file?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.