<?
function Error($msg)
{
/* funkcja wyswietla komunikat bledu pocztym konczy dzialanie programu. Wlasciwie
stanowi niejako alias do funkcji die() */
}
{
var $host; // host, z ktorym bedziemy sie laczyc
var $socket; // uchwyt
var $mail_subject; // temat listu
var $mail_sender; // nadawca
var $mail_recipient; // odbiorca
var $mail_content; // tresc
var $log; // log
function Mail($server_host) {
{
Error('Nie wpisałeś hosta, z którym mam się połączycš');
}
$this->host = $server_host;
}
function connect()
{
/* otwarcie gniazdka (laczenie sie z serwerem poczty) */
$this->socket = fsockopen($this->
;host
, 25
, $errno, $error, 30
); if (!$this->socket)
{
Error(\"$error ($errno)\");
}
/* wyslanie tekstu przywitalnego */
$this->send_cmd(\"HELO \" . $this->host . \"rn\");
}
function disconnect()
{
/* rozlaczenie z serwerem; przed tym nalezy jednak wyslac polecenie QUIT */
$this->send_cmd(\"QUITrn\");
}
function send_cmd($var_command)
{
/* funkcja wysyla do gniazdka polecenie z parametru $var_command oraz odczytuje o
powiedz
z serwera i przypisuja ja do zmiennej $log */
if ( fwrite($this->
;socket
, $var_command) >
; 0
) {
$this->log .= fgets($this->socket, 100) . '<br>'; }
}
function set_mail_sender($var_sender)
{
$this->mail_sender = $var_sender;
}
function set_mail_recipient($var_recipient)
{
$this->mail_recipient = $var_recipient;
}
function set_mail_subject($var_subject)
{
$this->mail_subject = $var_subject;
}
function set_mail_content($var_content)
{
$this->mail_content = $var_content;
}
function send_mail()
{
if (empty($this->
;mail_recipient
) || empty($this->
;mail_sender
)) Error
('Nie wpisałeś nadawcy lub odbiorcy e-maila!');
/* nadawca wiadomosci */
$this->send_cmd(\"MAIL FROM: <\" . $this->mail_sender . \">rn\");
/* odbiorca wiadomosci */
$this->send_cmd(\"RCPT TO: <\" . $this->mail_recipient . \">rn\");
/* informuje, ze zaraz rozpoczniemy wysylanie danych */
$this->send_cmd(\"DATArn\");
/* temat wiadomosci */
$this->send_cmd(\"Subject: \" . $this->mail_subject . \"rn\");
/* kodowanie */
$this->send_cmd(\"Content-type: text/html; charset=iso-8859-2rn\");
/* naglowki */
$this->send_cmd(\"From: \" . $this->mail_sender . \"rn\");
$this->send_cmd(\"Reply-To: \" . $this->mail_sender . \"rn\");
$this->send_cmd(\"Return-Path: \" . $this->mail_sender . \"rnrn\");
/* tresc wiadomosci */
$this->send_cmd($this->mail_content . \"rn\");
$this->send_cmd(\".rn\"); // koniec wiadomosci
}
}
$mail = new Mail(\"localhost'); $mail->set_mail_sender('xxx@o2.pl');
$mail->set_mail_recipient('root@localhost');
$mail->set_mail_subject('Testowy temat');
$mail->set_mail_content('Jakas tresc');
$mail->connect();
$mail->send_mail();
$mail->disconnect();
?>
?>
dlaczego to niedziała /serwer smtp argosoft, php 5.0.00
Ten post edytował DeyV 1.09.2004, 20:07:27