IT/Tips

메일 보내기

싸후이 2007. 4. 24. 17:37
function sendmail($to,$from,$subject,$message) {
   
    GLOBAL $MAILSERVER;
   
    # mail header 를 작성
    $mail_header =  "From: 관리자<$ADMIN_EMAIL>\n".
                    "Organization: Eyeopt, LTD\n".
                    "User-Agent: Eyeopt Mail System\n".
                    "X-Accept-Language: ko\n".
                    "X-Sender: <$ADMIN_EMAIL>\n".
                    "X-Mailer: Xirom Mail System\n".
                    "MIME-Version: 1.0\n".
                    "Content-Type: text/html; charset=EUC_KR\n".
                    "Content-Transfer-Encoding: 8bit\n".
                    "To: $to\n".
                    "Reply-To: $from\n".
                    "Return-Path: $from\n".
                    "Subject: $subject\n";
    $body = $mail_header.$message;
    $body = str_replace("\n","\r\n",str_replace("\r","",$body));
   
    # smtp port 에 socket 을 연결
    $socket = fsockopen($MAILSERVER,25,&$errno,&$errstr);
   
    if ($socket) {
        fputs($socket,"HELO <$HTTP_HOST>\r\n");
        fgets($socket,512);
        fputs($socket,"MAIL From: $from\r\n");
        fgets($socket,512);
        fputs($socket,"RCPT To: $to\r\n");
        fgets($socket,512);
        fputs($socket,"data\r\n");
        fgets($socket,512);
        fputs($socket,"$body\n.\r\n");
        fgets($socket,512);
        fputs($socket,"quit\r\n");
        fgets($socket,512);
    }
    else err_dis (" 메일 서버 접속 오류 잠시후 이용하세요 ");
   
    fclose($socket);
}

'IT > Tips' 카테고리의 다른 글

Ftp Protocol (active mode and pasv mode)  (0) 2007.05.08
ftp proxy howto  (0) 2007.04.26
일본어 메일 보내기  (0) 2007.04.24
Doxygen Quick Guide  (0) 2007.04.21
Change the color for Linux prompt  (0) 2007.04.05