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
maybelater
Forum Newbie
Posts: 3 Joined: Tue Mar 30, 2004 4:00 am
Post
by maybelater » Tue Mar 30, 2004 4:00 am
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
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Tue Mar 30, 2004 4:02 am
Try using \r\n where you have \n in the headers...and i don't actually see where you call mail() ?
maybelater
Forum Newbie
Posts: 3 Joined: Tue Mar 30, 2004 4:00 am
Post
by maybelater » Tue Mar 30, 2004 4:08 am
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 ...
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Tue Mar 30, 2004 4:14 am
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);
maybelater
Forum Newbie
Posts: 3 Joined: Tue Mar 30, 2004 4:00 am
Post
by maybelater » Tue Mar 30, 2004 4:58 am
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 ?