<? ######################### #1. TEIL zb. smtp.php # ######################### /* include(\"smtp.class.php\"); $smtp = new SMTP( $server, $user_name, $user_pass ); $error = $smtp->send( array( $HTTP_POST_VARS['target'] ), $HTTP_POST_VARS['subject'], $HTTP_POST_VARS['text'] ); if($error)echo$error; */ ######################### #2. Teil: smtp.class.php # ######################### /** * class: smtp.class.php * require: * optional: * description: class for sending mail directly throw an smtp server * created: 25.08.2002 * last change: 18.09.2002 * author: Sven Denkert <sven.denkert@t-online.de> * copyright: Sven Denkert * * TODO: MIME / Attachments / error-handling like pop3.class.php */ $_CLASS_SMTP_ = 1; class SMTP { var $server = \"\"; var $user_name = \"\"; var $user_pass = \"\"; var $from = \"ja@wp.pl\"; var $socket; var $error; function SMTP( $server, $user_name = null, $user_pass = null ) { if ( !$this->server = $server ) return $this->error = \"No SMTP server provided\"; } function &server_parse( $response ) { $server_response = \"\"; return $this->error = \"Couldn't get mail server response codes\"; return $this->error = \"Couldn't not send mail. Server response: $server_response\"; return \"\"; } function &put( $string ) { } // put in // mail_to => array of mailadresses, or string splittet with , // cc => array of mailadresses, or string splittet with , // cc => array of mailadresses, or string splittet with , function &send( $mail_to, $subject, $message, $cc = \"\", $bcc = \"\" ) { // Fix any bare linefeeds in the message to make it RFC821 Compliant. // $message = preg_replace( \"/(?<!r)n/si\", \"rn\", $message ); return $this->error = \"Could not connect to smtp host : $errno : $errstr\"; if ( $this->server_parse( \"220\" ) ) return $this->error; if ( !$this->put( \"EHLO \" . $this->server ) ) return $this->error = \"cannot send EHLO Command\"; if ( $this->server_parse( \"250\" ) ) return $this->error; if ( !$this->put( \"AUTH LOGIN\" ) ) return $this->error = \"Cannot send AUTH LOGIN Command\"; if ( $this->server_parse( \"334\" ) ) return $this->error; return $this->error = \"Cannot send LOGIN USER\"; if ( $this->server_parse( \"334\" ) ) return $this->error; return $this->error = \"Cannot send USER PASS\"; if ( $this->server_parse( \"235\" ) ) return $this->error; } if ( !$this->put( \"MAIL FROM: \" . $this->from ) ) return $this->error = \"Cannot send MAIL FROM\"; if ( $this->server_parse( \"250\" ) ) return $this->error; $to_header = \"FROM: <\" . $this->from . \"> rn\"; $to_header .= \"To: \"; $this->server_parse( \"250\" ); } $to_header .= \"$mail_to_address, \"; } $this->server_parse( \"250\" ); } } } $this->server_parse( \"250\" ); } } $to_header .= \"$cc_address,\"; } $this->server_parse( \"354\" ); $this->server_parse( \"250\" ); $this->socket = null; } } } ?>
i nie wiem jak dodac to tego skryptu naglowek aby mozna bylo wysylac e-miale w formacie html.
![worriedsmiley.gif](http://forum.php.pl/style_emoticons/default/worriedsmiley.gif)