954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Mail function

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.

CoolGamer48
Posting Pro in Training
401 posts since Jan 2008
Reputation Points: 77
Solved Threads: 40
 

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

kvdd
Junior Poster in Training
55 posts since Jun 2008
Reputation Points: 17
Solved Threads: 2
 

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

samarudge
Posting Whiz
359 posts since May 2008
Reputation Points: 26
Solved Threads: 31
 

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.

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You