Page 1 of 1

Problems with my mail() site HELP me PLEASE!

Posted: Tue Mar 30, 2004 4:00 am
by maybelater
Hey guys, please help me out.
My site doesn´t sent me any emails anymore. it used to work. Than I tried to adapt the code to give some sort of formmailer and all over sudden it doens´t work anymore...

here´s the code:
the form:
Admin Edit: added tags.[/size][/color]

Code: Select all

<form name="mailing=" method="POST" action="thankyou.php">
<table>
<tr>
<td align="left">Name:</td><td><input name="name" type="text" value=""></td>

</tr>
<tr>
<td align="left">Lastname:</td><td align="left"><input type="text" name="lastname" value=""></td>
<tr>
<td align="left">Email:</td><td align="left"><input name="email" type="text" value=""></td>
</tr>
<tr>
<td align="right"><input type="reset" value="RESET"></td><td align="left"><input type="submit" value="SUBMIT"></td>
</tr>
</form>

and here´s the php-code:

<?php

$name = $HTTP_POST_VARS["name"];
$lastname = $HTTP_POST_VARS["lastname"];
$email= $HTTP_POST_VARS["email"];
$subject = "new newsletter subscription";



if(strlen($_POST['name']) == 0){
$error="please enter a name.<br>";
}

if(strlen($_POST['lastname']) == 0){
$error="please enter a lastname.<br>";
}

if (!ereg("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}", $email)) {
$error.="please enter a valif email.<br>";
}

if($error){

echo "<b><font size='5' color='red'>it didn´t work out:</font></b><br><br>";

echo "<font color='red' size='5'>".$error."<br> Gleich gehts wieder zurück !!</font>";}

else{

$header = "From: <$email>\n"; 
$header .= "Reply-To: <$email\n"; 
$header .= "X-Mailer: PHP/" . phpversion(). "\n"; 
$header .= "X-Sender-IP: $REMOTE_ADDR\n"; 
$header .= "Content-Type: text/html"; 

$mailto = "myeamil@adress.de";
$mailfrom = $email;
$body = "<$name><$lastname><$email>\r\n";

?>
also I am entering the variables into a mysql database which still works fine. but there´s ne emails getting in.
PLEASE HELP ME !! ;-)


thanks in advance

Posted: Tue Mar 30, 2004 4:02 am
by markl999
Try using \r\n where you have \n in the headers...and i don't actually see where you call mail() ? :o

hmmm

Posted: Tue Mar 30, 2004 4:08 am
by maybelater
now that´s a good one...
me neither. could you post a code-correction please ?

damned. this happens when you work at home from work ... ;-)

Posted: Tue Mar 30, 2004 4:14 am
by markl999
Well, maybe something like..

Code: Select all

$header = "From: <$email>\r\n";
$header .= "Reply-To: <$email>\r\n";
$header .= "X-Mailer: PHP/" . phpversion(). "\r\n";
$header .= "X-Sender-IP: $REMOTE_ADDR\r\n";
$header .= "Content-Type: text/html";

$mailto = "myeamil@adress.de";
$mailfrom = $email;
$body = "<$name><$lastname><$email>\r\n";

mail($mailto, $subject, $body, $header);

I did that

Posted: Tue Mar 30, 2004 4:58 am
by maybelater
I added the code and now something odd happens:
I don´t have any message body in it...
the subject is there, the email-adress is right, it is delivered right. but no message body...

Admin edit (again): added tags - use them to make your code easier to read so that it's easier to help you.[/size][/color]

Code: Select all

else{

$header = "From: <$email>\n"; 
$header .= "Reply-To: <$email>\n"; 
$header .= "X-Mailer: PHP/" . phpversion(). "\n"; 
$header .= "X-Sender-IP: $REMOTE_ADDR\n"; 
$header .= "Content-Type: text/html"; 


$mailto  = "newsletter@baseball-ass.de";
$betreff = "Newsletter bestellung";
$body = "<$name><$lastname><$email>\r\n";
mail($mailto,$betreff,$body,$header);
delivers a great email, but with no text in it...any ideas ?