메일 보내기 소스 > PHP

본문 바로가기
사이트 내 전체검색

PHP

메일 보내기 소스

페이지 정보

profile_image
작성자 최고관리자
댓글 0건 조회 4,461회 작성일 21-02-09 11:33

본문

<?
        if($addhtml==y){
        //=html 사용여부. 사용하지 않을 경우 addhtml값을 입력할 필요 없게 하기 위해 y값 검사.
            $html = "$html";
        } else {
            $html = nl2br("$html");
        }


        // Body의 경계에 사용할 데이터를 구하기
        $boundary ='=_'.md5(uniqid(time()));
        //보내는 사람 - base64방식으로 엔코딩한다.
        $from = base64_encode($from);
        $from = "From: =?ks_c_5601-1987?B?$from?= <$from_email>";
        //받는 사람
        $to = base64_encode($to);
        $to = "To: =?ks_c_5601-1987?B?$to?= <$to_email>";

        $subject = base64_encode($subject);
        $subject = "Subject: =?ks_c_5601-1987?B?$subject?=";

        //헤더 작성-------------------------------------------
        $headers = "$from\r\n$to\r\n$subject\r\n";
        $headers.= "MIME-Version: 1.0\r\n";
        $headers.= "Content-Type: multipart/mixed;".chr(13).chr(10).chr(9)."boundary=\"$boundary\"\r\n\r\n";
       
        //바디 작성-------------------------------------------
        $body = "--".$boundary."\r\n";
        $body.= "Content-Type:text/html;\r\n";
        $body.= "Content-Transfer-Encoding:base64\r\n\r\n";

        $body.= chunk_split(base64_encode($html))."\r\n\r\n";
        $body.='--'.$boundary."--\r\n\r\n";

        //작성된 메일 전송하기--------------------------------
        //sendmail 경로 및 시행 옵션 where is sendmail 또는 which sendmail로 찾는다
        $MAILER="/usr/lib/sendmail -t -ba";
       
        //sendamil 프로세스 열기
        $fp =popen($MAILER,"w");
        if(!$fp){
        echo("프로세스 열기실패");
        }

        //프로세스로 데이터 보내기
        fputs($fp,$headers);
        fputs($fp,$body);
        if(!fputs)

        //프로세스 종료
        pclose($fp);
       
 ?>



 ----------------------------------------------------------
넘어 와야 하는 변수들..
1. from : 보내는이
2. from_email : 보내는이 이메일
3. to : 받는이
4. to_email : 받는이 이메일
5. subject : 제목
6. html : 내용

 위 소스는 파일 업로드 기능은 제외 시켰음..

 ##################   

        $detail = stripslashes($row[detail]);

        // 메일 보내기..
        $headers .= "From: 보내는이 <보낸 메일>\n"; //메일 보내는 사람
        $headers .= "X-Sender: <보낸 메일>\n"; //보낸 곳
        $headers .= "X-Mailer: 메일Engine\n"; //메일 엔진 이름
        $headers .= "Return-Path: 메일\n"; //메일보내기 실패했을경우 메일 받을 주소
        $headers .= "Content-Type: text/html; charset=EUC-KR\n";

        $contents = nl2br($detail);
               
        // 메일폼 html 소스 시작..........

        $h_contents = "
                  소스..... $contents
        ";
        // 메일폼 html 소스 끝..........
       
        $bodytext  = stripslashes($h_contents);
        $headers .= "\n\n";
        $title = "제목.";
        mail($row[email], $title, $bodytext,$headers);

댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

  • 게시물이 없습니다.

접속자집계

오늘
2,176
어제
4,039
최대
6,642
전체
830,691
contact : webmaster@beautipia.co.kr
Copyright © beautipia.co.kr. All rights reserved.