//SMTP_BEGIN
//---------------------------
class SMTP{
var $fp;
var $from;
var $to;
//------------------------
function SMTP(){
}
//------------------------
function conn(){
global $HTTP_HOST;
$this->fp = fsockopen("localhost", 25, &$errno, &$errstr, 30);
if(! $this->fp){die("sendmail ¿¬°á¿¡·¯: $errstr ($errno)");}
fgets($this->fp, 128);
fputs($this->fp, "helo <$HTTP_HOST>\r\n");
fgets($this->fp, 128);
}
//------------------------
function close(){
fclose($this->fp);
}
//------------------------
function set_from($from){
$this->from = $from;
fputs($this->fp, "mail from: <$this->from>\r\n");
fgets($this->fp, 128);
}
//------------------------
function set_to($to){
$this->to = $to;
fputs($this->fp, "rcpt to: <$this->to>\r\n");
fgets($this->fp, 128);
}
//------------------------
function send($subject, $body, $from_name = "", $to_name = "", $type = 1){
fputs($this->fp, "data\r\n");
fgets($this->fp, 128);
fputs($this->fp, "Return-Path: <$this->from>\r\n");
fputs($this->fp, "From: $from_name <$this->from>\r\n");
fputs($this->fp, "To: $to_name <$this->to>\r\n");
fputs($this->fp, "Subject: $subject\r\n");
if($type == 2){fputs($this->fp, "Content-Type: text/html;\r\n");}
fputs($this->fp, "\r\n");
fputs($this->fp, $body);
fputs($this->fp, "\r\n.\r\n"); //end of body
}
}//SMTP_END
| |