PDA

View Full Version : php mail issue



web2k
05-01-2008, 10:14 PM
Hi,
Can anyone run php mail function on bluhost shared hosting?

<?
$email='your@mail';
$subject='subject';
$message='message';

mail($email,$subject,$message) ;
echo "Done";
?>

When I run this , it's getting unusual time to process and giving "internal server error",
But this same function is working for other hosting provider..
Pls. help..

greenman
05-06-2008, 02:18 PM
Have you tried <?php ?> tags instead of <? ?> ?

Lophofo
05-06-2008, 04:13 PM
I've always found this script to be useful for testing the php mail() function:

<?php
error_reporting("E_ALL");
if (isset($_POST['submit']) && $_POST['submit'] == "Send Feedback") {
$errors = array();

foreach ($_POST as $key => $value) {
if ($value == "") {
switch($key) {
case "name":
$errors[] = "You DO have a name, don't you?";
break;

default:
$errors[] = "You forgot to fill in the $key field.";
break;
}
}
else { $$key = $value; }
}

// Define the format which the name and message will display in the email
$messagebody = "Name: $name\n\nMessage:\n$body";

if (!function_exists("mail")) { $message = '<font color="red">Please fill out the form again.</font>'; $errors[] = "No Mail Function"; }
elseif (!empty($errors)) { $message = '<font color="red">There are still errors!</font>'; }
else {
if (!mail("$email", "PHP Mail Tester","$messagebody", "From: $name <$from>")) {
$message = "Sending Failed.";
} else {
$message = "Thank you, <b>$name</b>, for the following message:<br /><tt>$body</tt>";
}
}
}

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Mail Tester</title>
</head>

<body>

<?
if (isset($message)) {
print "<div style='border:1px solid #cc0000;'>".$message."<br>";
if (!empty($errors)) {
print "<ul>";
foreach ($errors as $error) {
print "<li>".$error."</li>\n";
}
print "</ul>";
}
print "</div>"; }
?>

<form action="" method="post">
<table border="0" cellpadding="8" cellspacing="8" summary="feedback form">
<tr><td width="31"><font color="red">*</font>Name:</td>
<td width="217"><input type="text" name="name" size="25" value="<?=$name;?>"/></td></tr>
<tr>
<td><font color="red">*</font>Email:</td>
<td><input type="text" name="email" size="25" value="<?=$email;?>" /></td></tr>
<tr>
<tr>
<td><font color="red">*</font>From:</td>
<td><input type="text" name="from" size="25" value="<?=$from;?>" /></td></tr>
<tr>
<td colspan="2"><font color="red">*</font>Message: <br />
<textarea rows="15" cols="45" name="body"><?=$body;?></textarea>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<input name="submit" type="submit" value="Send Feedback" /></td>
</tr>
</table>
</form>
</body>
</html>

Also, remember to have a php.ini file in the same directory where you're running the php script from. The alternative is to enable PHP 5 (FastCGI) from the PHP Config icon inside the Software / Services section of cPanel.

dug
05-23-2008, 03:43 AM
The Php mail() function definitely works on Bluehost - I have numerous sites & apps that use it ( including OSCommerce & PHPWebsite CMS )