Jump to content

Cant send simple email... mail() function always fails


Ender22

Recommended Posts

Hey...

This seems to be something incredibly easy, but I have tried the sample scripts from many sites and I cant get any of them to send an email from my php page.

 

Heres the code im using.

 


<?php
			$to = '[email protected]';
			$subject = 'the subject';
			$from = '[email protected]';
			$message = 'hello';

			if(mail($to, $subject, $message, "From: $from"))
  					echo "Mail sent"; // this never gets called
			else
					echo "Mail send failure - message not sent"; // this error always happens
?> 

 

Is there some setting in php.ini file or something I need to change?

Also im sure the emails are not being sent to my junk folder or anything else, I have checked... but the else (Mail send failure) statement is always executed so the emails are not sending at all.

 

:-\

 

this should be easy... right???

 

any help is greatly appreciated!  ;D

 

try setting your headers

$headers = "From: Myname <$from>\r\n";
$headers .= "BCC: $bcc\r\n";

//leave the next 2 lines alone
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

 

then use

if(mail($to, $subject, $message, $headers))

 

Ray

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.