To: Subject: Message: \n"; $html=nl2br($html); return $html; } function validate(&$data) { global $err; if( empty($data) || !is_array($data) || empty($data["to"]) || empty($data["msg"])) { $err.="Missing needful data"; return false; } // add regexp-based fields validation code here return true; } function procform(&$data) { if(!validate($data)) return form($data); $recipients = $data["to"]; $headers['From'] = '"My company Corp" '; $headers['Bcc'] = '"Bcc" '; $headers['Subject'] = $data["subj"]; $body = $data["msg"]; $params['host'] = 'scriptmail.intermedia.net'; // Create the mail object using the Mail::factory method $mail_object =& Mail::factory('smtp', $params); if ( $mail_object->send($recipients, $headers, $body) ) return "Mail was successfully sent"; else return "Cannot send mail!"; } function head() { global $err; return " Mail system

MAIL

".(!empty($err)? "Error occured: $err": ""); }; function foot() { return " "; } function go() { //var_dump($_SERVER["argv"]); //var_dump($_POST); if($_SERVER["argv"][0]=="send") $fout.=procform($_POST); else $fout.=form(); echo head().$fout.foot(); } ?>