Small Problem With Sendmail
Posted: Tue Jan 09, 2007 3:25 pm
Hello, I found a sendmail script on some website and I have edited it to send what I need to an email address and it works fine except for one thing. When I check my inbox it has a blank where the email should be.
Here is the code:
I commented out what I think the problem is.
Any help would be great.
[right]Thank You[/right]
Here is the code:
Code: Select all
<?php
// put the emails of recipients here.
// seperate multiples by a comma a@a.co.uk, b@b.co.uk
// leave it alone for script to try and work it out.
$domain_name = eregi_replace("www.","",$SERVER_NAME);
$email_to = "origin@$domain_name";
// now this bit is a little bit clever it ASCII encodes
// the above email addresss for a link. (@ LINE 102)
// It's to help stop spambots from harvesting your email address.
function ascii_encode($str){
global $encoded;
$encoded="";
for ($i=0; $i < strlen($str); $i++){
$encoded .= '&#'.ord(substr($str,$i)).';';
}
return;
}
// this function just displays the errors, you need a
// class ".err" in the css for it to highlight properly.
// I've put a little something in above...
function err_display($err_array, $err){
if ($err_array["$err"]){
print ("<tr class=err>");
}else{
print ("<tr>");
}
}
// ORiGIN: I think the errors come from this, so I commented some out, this is why from email wont show up
//if (!isset($referer_url)){
// let's try something!
//$referer_url = $HTTP_REFERER;
//}
if ($submit){
// do some testing?
//if ($real_name == ""){
// $err_array[real_name] = "<b>Error</b> please complete your first name.";
//}
//if ($user_name == ""){
//$err_array[user_name] = "<b>Error</b> please enter your username.";
//}
//if ($email != "" ){
//$email = trim($email);
//if(!ereg("([_a-z0-9A-Z\d\-\.]+@[_a-z0-9A-Z\d\-]+(\.[_a-z0-9A-Z\d\-]+)+)",$email,$regs)){
//$err_array[email] = "<b>Sorry</b> your email address ($email) doesn't appear to be valid";
//}
//else{
//$err_array[email] = "<b>Error</b> please enter your email address.";
//}
$err_count = count($err_array);
if ($err_count != 0){
print ("<p class=err>Please correct the $err_count error(s):");
while (list($index,$value) = each($err_array)){
print ("$value<br>");
}
print ("</p>");
}else{
reset($HTTP_POST_VARS);
while (list($key,$val) = each($HTTP_POST_VARS)){
$message .= "$key: $val\n";
print ("$key: $val<br>");
}
$email_headers = "From: $username<$email>\n";
$email_subject = "Application";
// this sends the email using the standard php mailer (sendmail?)
@mail($email_to, $email_subject, $message, $email_headers);
// Here's your thank you note...
print ("<h2>Thank you $firstname!</h2>");
}
}
if (!$submit OR $err_count != "0"){
ascii_encode("$email_to");
print ("<p>Please use the form to send a message to <a href=\"mailto:$encoded\">$encoded</a></p>");
print ("<form action=\"sendmail.php\" method=\"POST\">");
print ("<table>\n<tr>");
//err_display($err_array, real_name);
print ("<td>Real Name:</td><td><input type=\"text\" size=14 size=14 name=\"Name\" value=\"$real_name\"></td></tr>\n<tr>");
//err_display($err_array, username);
print ("<td>Username:</td><td><input type=\"text\" size=14 name=\"Username\" value=\"$username\"></td></tr>");
print ("<tr>");
print ("<td>Age:</td><td><input type=\"Text\" name=\"Age\" value=\"$age\"></td></tr>\n");
//err_display($err_array, e_mail);
print ("<tr><td>Email:</td><td><input type=\"Text\" name=\"Email\" value=\"$e_mail\"></td></tr>\n");
//err_display($err_array, JoinApp);
print ("<tr><td>Xfire:</td><td><input type=\"Text\" name=\"Xfire\" value=\"$xfire\"></td></tr>\n");
print ("<tr><td>Location:</td><td><input type=\"Text\" name=\"Location\" value=\"$loc\"></td></tr>\n");
print ("<tr><td>Who Refered You?</td><td><input type=\"Text\" name=\"Referer\" value=\"$hear_about_us\"></td></tr>\n");
print ("<tr><td> </td><td><input name=\"submit\" type=\"Submit\" value=\"Send\"></td></tr>\n");
print ("</table>");
print ("<input type=\"Hidden\" name=\"IP\" value=\"$REMOTE_ADDR\">");
print ("</form>");
}
?>Any help would be great.
[right]Thank You[/right]