관리 메뉴

엉망진창

php 전체 메일 본문

Study_Web/PHP

php 전체 메일

엉망진창 2007. 4. 23. 16:41
원문

<?
    include('../../control/stdlib.inc') ;
    $connid = connect2db() ;

    $mailheaders .= "Return-Path: $from\r\n";
    $mailheaders .= "From: $rn <$from>\r\n";
    $mailheaders .= "X-Mailer: InoS Mailer\r\n";
    $mailheaders .= "Reply-To: $from \r\n";
    $mailheaders .= "Content-Type:text/html;charset=euc-kr \n";

    $db_result = mysql_query("select email from 테이블명 order by num limit 0,150 ") ;
    $db_total = mysql_num_rows($db_result);
        
    
    if(!$db_total){
        echo("<br><br>");
        echo("<font style='font-size:9pt;' color=green><center>메일을 보낼 회원이 없습니다.</center></font>");
        echo("<br>");
        
        exit;
    }

    if ($userfile && $userfile_size) {
                
          $filename=basename($userfile_name);
          $result=fopen($userfile,"r");
          $file=fread($result,$userfile_size);
          fclose($result);

    
          if ($userfile_type == "")
        {
                $userfile_type = "application/octet-stream";
            }

          $boundary = "--------" . uniqid("part");

          $mailheaders .= "MIME-Version: 1.0\r\n";
          $mailheaders .= "Content-Type: multipart/mixed; boundary=\"$boundary\"";

          $bodytext  = "This is a multi-part message in MIME format.\r\n\r\n";
          $bodytext .= "--$boundary\r\n";

          $bodytext .= "Content-Type: text/html; charset=euc-kr\r\n";
          $bodytext .= "Content-Transfer-Encoding: 8bit\r\n\r\n";

          $bodytext .= nl2br(stripslashes($body)) . "\r\n\r\n";
          $bodytext .= "--$boundary\r\n";
          $bodytext .= "Content-Type: $userfile_type; name=\"$filename\"\r\n";
          $bodytext .= "Content-Transfer-Encoding: base64\r\n\r\n";
          $bodytext .= ereg_replace("(.{80})","\\1\r\n",base64_encode($file));
          $bodytext .= "\r\n--$boundary--" . "\r\n";
      }
      else {
          $bodytext  = stripslashes($body);
      }
    
    
    for($counter=0;$counter<$db_total; $counter++)
    {
        $user_id = mysql_result($db_result, $counter, "email");
        mail($user_id,$subject,$bodytext,$mailheaders);
    }
    
    echo("<br><br>");
    echo("<font style='font-size:9pt;' color=green><center> 총 $db_total 명에게 메일을 성공적으로 보냈습니다.</font></center>");
    echo("<center><p><a href='newsletter_test.php'> <img src=/icon/first.gif border=0></a></center>");
    echo("<br><br>");
        
?>

'Study_Web > PHP' 카테고리의 다른 글

php 메일 (첨부파일가능)  (0) 2007.06.08
그누보드4에서의 멀티업로드  (3) 2007.05.01
[펌]실시간 쪽지 PHP  (0) 2007.04.23
php 함수 일부  (0) 2007.04.19
[펌] XAMPP - Apache MySQL PHP., 설치없이쓰는 APM환경  (0) 2007.03.16