Error when using mail() function!!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fredyfonda
Forum Newbie
Posts: 6
Joined: Tue Feb 28, 2006 1:54 am
Contact:

Error when using mail() function!!!

Post by fredyfonda »

Help!!!

I don't know what is the error :?:

I'm using mail() function to send email using php. I have upload it to server and run the code.
But I have error like this :

Warning: Server Error in c:\apache\htdocs\admindealersendpasswordprocess.php on line 48

I have check itu line 48 is my mail() function code, I have re-check my code and didn't find any problem with the script. Please help me, I don't know other way to send email using PHP except using mail() function.

I'm using Apache 1.3.23, PHP 4.1.1, and mySql 3.23.48 for my server.

Thanks for the help.
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

can we see the source?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Error when using mail() function!!!

Post by Chris Corbyn »

fredyfonda wrote:Please help me, I don't know other way to send email using PHP except using mail() function.
See the link in my signature ;)
fredyfonda
Forum Newbie
Posts: 6
Joined: Tue Feb 28, 2006 1:54 am
Contact:

here is the code

Post by fredyfonda »

Code: Select all

<?
	$dbname = "sahitel";
	$host   = "localhost";
	$user = "";
	$password = "";

	$con    = mysql_connect($host,$user,$password);
		
	if(!($con))
	{
		echo "Tidak Bisa Terkoneksi ke Database";
		exit;
	}
	
	mysql_select_db($dbname,$con);


	$email = $_REQUEST['email'];
	$err = "no";

	$to      = 	$email;
	$subject = "activision your Sahitel newsletter";
	$message = "
				<html>
				<head>
				<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
				</head>
				
				<body>
				<table width='100%' border='0' cellspacing='0' cellpadding='0'>
				  <tr> 
					<td colspan='3'>Thank you for subscribing to Sahitel newsletter</td>
				  </tr>
				  <tr>
					<td colspan='3'>&nbsp;</td>
				  </tr>
				  <tr> 
					<td colspan='3'><p>Please click the link below to activate your newsletter 
						account</p></td>
				  </tr>
				  <tr> 
					<td colspan='3'>subscribeProcess.php</td>
				  </tr>
				  <tr> 
					<td colspan='3'>&nbsp;</td>
				  </tr>
				  <tr> 
					<td colspan='3'>To de-activate your newsletter account, please click the link 
					  below </td>
				  </tr>
				  <tr> 
					<td colspan='3'>subscribeProcess.php</td>
				  </tr>
				</table>
				
				</body>
				</html>";
	$headers  = "MIME-Version: 1.0". "\r\n";
	$headers .= "Content-type: text/html; charset=iso-8859-1". "\r\n";
	$headers .= "To: $email". "\r\n";
	$headers .= "From: http://www.sahitel.com";

	function cek_email($content)
	{
		$results = ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $content, $trashed);
		if($results) return true;
		else return false;
	}

	if(!cek_email($email)) $err="yes";
	
	if($err=="yes")
	{
		header("location:index.php?errormail=$err");
	}
	else
	{
		mail($to, $subject, $message, $headers);
		header("location:index.php?errormail=noerror");
	}
?>
Post Reply