not sending mail

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
gecko
Forum Commoner
Posts: 34
Joined: Thu Oct 24, 2002 3:45 am

not sending mail

Post by gecko »

i am using the mail() function. the problem is that when I use the script on one server all goes well. when i use the script on an other server, the mail is only sent to people that have web email boxes like hotmail.com, but not received by people using for exampe outlook. Any idea why this might be?

this is the script i am using:

<?php
/* First display the code for the form */
if (!$email) {
if ($email="")echo "please fil in";
function emailcheck($intext) {
$theresults = ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $intext, $trashed);
if ($theresults) { $isamatch = "Yes"; } else { $isamatch = "Please check the format of your email address"; }
echo("$isamatch<br>\n");
}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Pampers e-mail form</title>


</head>

<body>



<?php
emailcheck("$email");
/* This is de part where the HTML mail is sent to $email */
} else {
/* Email sender */
$from = "hansie";

/* subject */
$subject = "hansie_mail";

/* message */
$message = '
<html>
<head>
<title>Mail</title>
</head>
<body bgcolor="#CCFFCC" >
<form method="post" action="http://www.whatever.com" id=form1 name=form1>
Email Address: <input name="email" size="32"> <input type="submit" value="Submit" name="submit">
</form>
</body>
</html>
';

/* headers */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: ".$from."\r\n";

/* and now mail it */
mail($email, $subject, $message, $headers);

/* display text on screen */
echo 'E-mail succesfully sent to: '.$name.'.';
}
?>

<?php if (!$email) { ?>
Please ensure you have completed
</body>
</html>
<?php } ?>
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post by delorian »

First of all, Outlook is not the problem, because it is a client program not server. I would rather check if the register_globals directive is set to "on" on your server and set to "off" on this "other" server.

http://pl.php.net/manual/en/configurati ... ctives.php

If you will be able to get this to work I have got one hint: do not use \r\n - Outlook and The Bat doesn't like it :D use \n instead.
Post Reply