BLS Posted February 2, 2008 Share Posted February 2, 2008 OK...so long story short, I got stuck trying to fix a PHP code problem, and I'm a server administrator, not a developer. I've got a site I moved from one server to another (now hosting it on our server), and a PHP page isn't working. If you goto http://www.laser1tech.com/contact.htm you'll see a form for contact info. Fill it out, click submit...you get this: Warning: mail() [function.mail]: SMTP server response: 501 5.5.4 Invalid Address in C:\Inetpub\wwwroot\Laser1tech\evm_mailer.php on line 592 Seems pretty obvious...even for a dumb server admin like me right? I can't find an email address anywhere in the evm_mailer.php file anywhere. I would like to know what the problem is, and I'd also like to know how to modify the address it gets sent to. I'll even post the code here: <?php class EVM_Mailer { var $subject = ""; var $Sendername = ""; var $Senderaddy = ""; var $message = ""; var $Recipients = ""; var $CC_list = ""; var $BCC_list = ""; var $attachments = array(); // filename(as attachment name),location(path+filename of attachment),mime-type var $ishtml = 0; // 0=text, 1=html var $warnings = array(); var $action_msgs = array(); var $error_msgs = array(); function get_file($filename){ if ($fp = fopen($filename, 'rb')) { $return = fread($fp, filesize($filename)); fclose($fp); return $return; } else { return FALSE; } } function set_subject($msg) { if (strlen($msg) > 255) { // Limit subject line to 255 characters $msg = substr($msg,0,255); array_push($this->warnings,"Subject line was truncated to 255 characters."); } $this->subject = $msg; array_push($this->action_msgs,"Subject line set to: " . $msg); } function set_sender($name,$addy) { if (strlen($addy) > 255) { // Limit sender address to 255 characters $array_push($this->error_msgs,"Sender email address too long. (255 char max)"); } else { if (strlen($name) != 0) { $this->Sendername = $name; array_push($this->action_msgs,"Sender name set to: " . $name); } else { array_push($this->action_msgs,"Sender name not set (empty field)"); } if (strlen($addy) == 0) { array_push($this->error_msgs,"Sender email address too short or invalid"); } else { // validate email address here if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $addy)) { array_push($this->error_msgs,"Email address not correctly formatted"); } else { array_push($this->action_msgs,"Email address format has been validated"); $this->Senderaddy = $addy; } } } } function set_message($msg) { $this->message = $msg; array_push($this->action_msgs,"Email message set"); } function add_recipient($name,$addy) { if (strlen($addy) > 255) { // Limit sender address to 255 characters $array_push($this->error_msgs,"Recipient email address too long. (255 char max) " . $addy); } else { if (strlen($name) == 0) { array_push($this->warnings,"No recipient name for " . $addy); } else { $build_address = (strlen($name) == 0) ? $name . " " : ""; $build_address .= "<"; $build_address .= $addy; $build_address .= ">"; if (count($this->Recipients) > 1) { $this->Recipients .= ", " . $build_address; array_push($this->action_msgs,"Recipient added: " . $addy); } else { $this->Recipients .= $build_address; array_push($this->action_msgs,"Recipient added: " . $addy); } } } } function add_CC($name,$addy) { if (strlen($addy) > 255) { // Limit sender address to 255 characters $array_push($this->error_msgs,"CC email address too long. (255 char max) " . $addy); } else { if (strlen($name) == 0) { array_push($this->warnings,"No CC name for " . $addy); } else { $build_address = (strlen($name) == 0) ? $name . " " : ""; $build_address .= "<"; $build_address .= $addy; $build_address .= ">"; if (count($this->CC_list) > 1) { $this->CC_list .= ", " . $build_address; array_push($this->action_msgs,"CC added: " . $addy); } else { $this->CC_list .= $build_address; array_push($this->action_msgs,"CC added: " . $addy); } } } } function add_BCC($name,$addy) { if (strlen($addy) > 255) { // Limit sender address to 255 characters $array_push($this->error_msgs,"BCC email address too long. (255 char max) " . $addy); } else { if (strlen($name) == 0) { array_push($this->warnings,"No BCC name for " . $addy); } else { $build_address = (strlen($name) == 0) ? $name . " " : ""; $build_address .= "<"; $build_address .= $addy; $build_address .= ">"; if (count($this->BCC_list) > 1) { $this->BCC_list .= ", " . $build_address; array_push($this->action_msgs,"CC added: " . $addy); } else { $this->BCC_list .= $build_address; array_push($this->action_msgs,"CC added: " . $addy); } } } } function add_attachment($aname,$location,$mimetype) { // ----------------------------------------------------------------- // The following code checks the mime-type passed to the object vs. // mime-types available to PHP on the server. If you want to ensure // that all mime-types are accepted, comment out this code. if (function_exists('mime_content_type')) { $vmime = mime_content_type($location); if ($vmime == $mimetype) { array_push($action_msgs,"mime type validated"); } } // ----------------------------------------------------------------- if ($mimetype == "") { array_push($this->error_msgs,"No mime type for attachment: " . $location); } if ($aname == "") { array_push($this->error_msgs,"No attachment name specified for attachment: " . $location); } if ($location == "") { array_push($this->error_msgs,"No file name specified for attachment"); } else { if (!file_exists($location)) { array_push($this->error_msgs,"attachment: " . $location . " does not exist"); } else { if (!is_readable($location)) { array_push($this->error_msgs,"attachment: " . $location . " could not be read"); } else { $toarray = $aname; $toarray .= ","; $toarray .= $location; $toarray .= ","; $toarray .= $mimetype; array_push($this->attachments,$toarray); array_push($this->action_msgs,$location . " set as attachment"); } } } } function set_message_type($mtype) { switch ($mtype) { case "text": $this->ishtml = 0; array_push($this->action_msgs,"Message body set to text"); break; case "html": $this->ishtml = 1; array_push($this->action_msgs,"Message body set to html"); break; default: $this->ishtml = 0; array_push($this->action_msgs,"Message body set to text"); break; } } function get_actions() { $returnstring = ""; if (count($this->action_msgs) > 0) { for ($i=0;$i<count($this->action_msgs);$i++) { $returnstring .= $this->action_msgs[$i] . "<br>\n"; } } return $returnstring; } function get_warnings() { $returnstring = ""; if (count($this->warnings) > 0) { for ($i=0;$i<count($this->warnings);$i++) { $returnstring .= $this->warnings[$i] . "<br>\n"; } } return $returnstring; } function get_errors() { $returnstring = ""; if (count($this->error_msgs) > 0) { for ($i=0;$i<count($this->error_msgs);$i++) { $returnstring .= $this->error_msgs[$i] . "<br>\n"; } } return $returnstring; } function send() { $IP = @getenv('HTTP_X_FORWARDED_FOR') ? @getenv('HTTP_X_FORWARDED_FOR') : @getenv('REMOTE_ADDR'); if (count($this->error_msgs) == 0) { $boundary = '=_'.md5(uniqid(rand()).microtime()); $headers = "MIME-Version: 1.0\r\n"; $headers .= "Date: ". date("r",time()) . "\r\nFrom: "; $headers .= ($this->Sendername == "") ? "" : $this->Sendername . " "; $headers .= "<"; $headers .= $this->Senderaddy; $headers .= ">[{$IP}]\r\n"; $headers .= "To: "; $headers .= $this->Recipients; $headers .= "\r\n"; if (strlen($this->CC_list) > 0) { $headers .= "CC: "; $headers .= $this->CC_list; $headers .= "\r\n"; } if (strlen($this->BCC_list) > 0) { $headers .= "BCC: "; $headers .= $this->BCC_list; $headers .= "\r\n"; } $headers .= "Content-Type: multipart/mixed; boundary=\"" . $boundary . "\"\r\n"; $headers .= "Content-Transfer-Encoding: 8bit\r\n"; $meat = "--$boundary\r\n"; if ($this->ishtml == 0) { $meat .= "Content-Type: text/plain; charset=\"utf-8\"\r\n"; } if ($this->ishtml == 1) { $meat .= "Content-Type: text/html; charset=\"utf-8\"\r\n"; } $meat .= "Content-Transfer-Encoding: 8bit\r\n\r\n"; $meat .= $this->message; $meat .= "\r\n\r\n\r\n--"; $meat .= $boundary; $meat .= (count($this->attachments) > 0) ? "\r\n" : "--\r\n"; if (count($this->attachments) > 0) { set_magic_quotes_runtime(0); for ($j=0;$j<count($this->attachments);$j++) { $last_attachment = count($this->attachments) - 1; list($filename,$location,$mimetype) = split(',',$this->attachments[$j]); $meat .= "Content-Type: "; $meat .= $mimetype; $meat .= "; name=\""; $meat .= $filename; $meat .= "\"\r\n"; $meat .= "Content-Transfer-Encoding: base64\r\n"; $meat .= "Content-Disposition: attachment\r\n\r\n"; $meat .= rtrim(chunk_split(base64_encode($this->get_file($location)))); if ($j == $last_attachment) { $meat .= "\r\n--"; $meat .= $boundary; $meat .= "--"; } else { $meat .= "\r\n--"; $meat .= $boundary; $meat .= "\r\n"; } } set_magic_quotes_runtime(get_magic_quotes_gpc()); } mail($this->Recipients,$this->subject,$meat,$headers); return TRUE; } else { return FALSE; } } } ?> mod edit: code tags added. Please read forum guidelines Quote Link to comment https://forums.phpfreaks.com/topic/89079-solved-newbie-needs-help-with-simple-php-problem/ Share on other sites More sharing options...
BLS Posted February 2, 2008 Author Share Posted February 2, 2008 Sorry Mods....first time on a developer forum. Quote Link to comment https://forums.phpfreaks.com/topic/89079-solved-newbie-needs-help-with-simple-php-problem/#findComment-456242 Share on other sites More sharing options...
revraz Posted February 2, 2008 Share Posted February 2, 2008 Well based on the error Invalid Address in C:\Inetpub\wwwroot\Laser1tech\evm_mailer.php on line 592 Check line 592 and look at the Address Quote Link to comment https://forums.phpfreaks.com/topic/89079-solved-newbie-needs-help-with-simple-php-problem/#findComment-456246 Share on other sites More sharing options...
BLS Posted February 2, 2008 Author Share Posted February 2, 2008 That's awfully funny. Because I'm pretty sure I'm not going to count 592 lines of code. But thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/89079-solved-newbie-needs-help-with-simple-php-problem/#findComment-456252 Share on other sites More sharing options...
AndyB Posted February 2, 2008 Share Posted February 2, 2008 That's awfully funny. Because I'm pretty sure I'm not going to count 592 lines of code. Don't you have an editor that provides line numbering?? Quote Link to comment https://forums.phpfreaks.com/topic/89079-solved-newbie-needs-help-with-simple-php-problem/#findComment-456257 Share on other sites More sharing options...
BLS Posted February 2, 2008 Author Share Posted February 2, 2008 That's awfully funny. Because I'm pretty sure I'm not going to count 592 lines of code. Don't you have an editor that provides line numbering?? No. But that would be pretty cool if I did. I'm NOT a developer. I'm an Network Engineer. I might as well be trying to figure a satellite trajectory...I have zero clue what I'm doing with this stuff. Quote Link to comment https://forums.phpfreaks.com/topic/89079-solved-newbie-needs-help-with-simple-php-problem/#findComment-456267 Share on other sites More sharing options...
PHPoracle Posted February 2, 2008 Share Posted February 2, 2008 Use Dreamweaver or PHPdesigner. Quote Link to comment https://forums.phpfreaks.com/topic/89079-solved-newbie-needs-help-with-simple-php-problem/#findComment-456276 Share on other sites More sharing options...
JustinM01 Posted February 3, 2008 Share Posted February 3, 2008 That's awfully funny. Because I'm pretty sure I'm not going to count 592 lines of code. But thanks for the help. No offense here, but that wouldn't take more than five minutes. So, you have to ask yourself if that 5 minutes of boredom is worth it. While you're waiting for a fix here that website is exposing your underlying directory structure, what webserver you're using, and the name of the php file that's causing the problem. Hopefully you have the site disabled or otherwise not actually hooked up the web right now. BTW, if you're unwilling to do, I'm not sure why you would expect us to. Quote Link to comment https://forums.phpfreaks.com/topic/89079-solved-newbie-needs-help-with-simple-php-problem/#findComment-456537 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.