Page 1 of 1
Error when using mail() function!!!
Posted: Wed May 24, 2006 1:17 pm
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.
Posted: Wed May 24, 2006 1:26 pm
by PrObLeM
can we see the source?
Re: Error when using mail() function!!!
Posted: Wed May 24, 2006 1:57 pm
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

here is the code
Posted: Sun May 28, 2006 11:56 am
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'> </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'> </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");
}
?>