강의 컨설팅 트레이닝 무료진단 무료책자 마케팅편지 마케팅정보공유 다이어리 서비스제휴 고객센터

php 대용량 메일
작성자 : 13 김영철
등록날짜 : 2009.01.13 14:42
3,024
★대용량 메일링 sendmail+PHP4.2 CLI

mass large mailing sendmail PHP



별도 메일 서버 구축으로 하루 10-20 만개 이상 메일 보내기



ram: 512 or 1G 정도

CPU: 팬4 1G 정도

PHP버전: 4.2.x 이상

Sendmail 버전: 8.12.x 이상

파일시스템: 저널링(ext3 or 다른것들 )



=================================================



# php -q mail_sender1.php

1h1]@Z <ehdgns777@@nexonclub.com>... Invalid route address

Syntax error in mailbox address "cccvcc@??????.com" (non-printable character)

Syntax error in mailbox address "5??dake1004@hanmir.com" (non-printable character)

@eGQ:{ <ky5640@.dreamwiz.com>... Invalid host name

9i<:Hl <www.qortnqorwh.@.yahoo.co.kr>... Invalid host name

kr>... Unbalanced '>'

1h@N?l <okm542588@yahoo.co,kr>... Unbalanced '<'

1h@N?l <okm542588@yahoo.co... Unbalanced '<'

kr>... Unbalanced '>'

kr>... Unbalanced '>'

1h@N?l <okm542588@yahoo.co,kr>... Unbalanced '<'

kr>... Unbalanced '>'

1hEB>g <tayure@.naver.com>... Invalid host name

A$0\?n <kumsimwarez@.com.ne.kr>... Invalid host name

@LAv?u <scmi@tood@toodent.com>... Invalid route address

Syntax error in mailbox address "k8983@??????.com" (non-printable character)

죽었음



--------------------------------------------------------------

<?php

//php -q mail_sender1.php

$code=0;



$k1=3;

$filename = "/home/mailing/homepage/mailing/up/".$k1.".txt";

$newfile = file($filename);



$nums=count($newfile);



for (
$k=0;$k<$nums;$k++){

$newfiles=explode("_T_",$newfile[$k]);



$id=$newfiles[0];

$email=$newfiles[1];

$name= $newfiles[2];

$year=$newfiles[3];



//print "$id,$email,$name,$year \n";



$to  = "$name <$email>"; // 콤마로 여러명에게

$subject="[tood 제목] ";



include
"up/tood20031210.php";



$from="help@tood.net";



$headers  = "MIME-Version: 1.0\r\n";

$headers .= "Content-type: text/html; charset=euc-kr\r\n";

$headers .= "From: tood <$from>\r\n";

mail($to, $subject, $message, $headers,"-f$from");



    if((
$code%100)==0){

        print
$email."\n";

    }

    
$code++;

}



?>



--------------------------------------------------------------

메일주소가 한글이라 오류가 발생하지만, 다음 메일은 메일을 발송한다.



php -q mail_sender2.php

Syntax error in mailbox address "sukhoi@????.com" (non-printable character)

--------------------------------------------------------------

메일주소가 다음과 같이 콤마(,)일 경우 오류 발생시킨다. sukhoi@empal,com



com>... Unbalanced '>'

@L?59+ <sukhoi@empal,com>... Unbalanced '<'

@L?59+ <sukhoi@empal... Unbalanced '<'

com>... Unbalanced '>'

com>... Unbalanced '>'

@L?59+ <sukhoi@empal,com>... Unbalanced '<'

com>... Unbalanced '>'

--------------------------------------------------------------

다음과 같이 오류 발생 시킴

@L?59+ <sukhoi@.empal.com>... Invalid host name



--------------------------------------------------------------

scmi@tood@toodent.com 다음과 같이 오류

@LAv?u <scmi@tood@toodent.com>... Invalid route address



--------------------------------------------------------------

메일주소에 한글이 있거나, 골뱅이(@)가 1개 이상일 경우나, 마침표외에 콤마 일 경우.

메일주소에서 영문하고, 골뱅이,점만 가능해야 한다. 글구 골뱅이와 쩜은 1개여야 한다.



--------------------------------------------------------------

sukhoi@empalfdkdfodfk90.com 도메인이 틀릴 경우는 오류발생하지 않음



--------------------------------------------------------------



메일링 로그 - procmail , sendmail



이 처방전은 제목이 test인 메일만 로그를 남기는 처방입니다. 모든 메일에 대해 로그를 남기고 싶으시면



* ^Subject:.*



와 같이 바꾸시면 됩니다.

그리고 $SENDMAIL -oi -f와 같이 f옵션을 사용하면 "X-warning....."라는 경고메세지가 쌓이게 됩니다. f옵션은

센드메일이 보내는 사람의 주소를 envelope가 아닌 command line에서 읽어들이도록 하는 옵션이다. 이렇게 되면

전송하는 메일이 가짜메일가능성이 있다는 점에서 경고메세지가 나옵니다.





=================================================

Sendmail.cf 파일





# minimum time in queue before retry

# 메일 전송 실패 할 경우 큐에 저장한 후에 30분 후에 재 전송

O MinQueueAge=30m



# how many jobs can you process in the queue?

# 큐에서 1번에 보낼 수 있는 메일 수

O MaxQueueRunSize=10000



파일 시스템 최소 여유공간 늘리기

O MinFreeBlocks=4000



메일 용량 늘리기 기본 10메가

#O MaxMessageSize=1000000



=================================================



--------------------------------------------------------------

대량 메일 발송 일 경우에 100명 마다 파일에 기록 !

100명 한테 메일 보내고 성공 OK 메시지 기록





--------------------------------------------------------------

아래가 로그 파일 입니다. 로그 파일을 보면 메일 보내기 실패 원인- 받기 실패 원인을 알 수 있습니다.

보내기가 안될 경우 로그 파일을 카피 해서 그 부분만 올려 주세요.

# vi  /var/log/maillog



# vi  /var/log/maillog.1



# vi  /var/log/maillog.2

--------------------------------------------------------------

썬 서버 메일 로그



/var/log/syslog and /var/adm/messages



--------------------------------------------------------------

메일로그 분석



내 DNS가 틀렸을 경우

stat=Deferred: Connection reset by smtp.sayclub.com.



메일 보내짐. 큐에 쌓여 있으나, 성공적으로 보내졌는지는 알지 못함 !

stat=Sent (hBF2Cq4O006059 Message accepted for delivery)



Deferred로 된것은 메일 발송 실패 !

stat=Deferred: Connection timed out with a.mx.naver.co.kr



stat=Deferred: 450 mailbox full



stat=Deferred: 451 <root@localhost.localdomain> unable to verify address



stat=Deferred: Connection refused by hanir.com.



stat=User unknown



stat=Deferred: 450 <root@localhost.localdomain>: Sender address rejected: Domain not found









mymylife0508@sayclub.com



5천개 발송하고 죽은듯 !



파일을 5천개 씩 나눠서 발송 해라 !





=================================================

[mailing@localhost mailing]$ date

2003. 12. 15. (월) 12:13:47 KST

[mailing@localhost mailing]$ php -q mail_sender3.php

5200개 발송 시작 !







=================================================

네이버,엠팔,다음,네띠앙,코리아닷컴,네이트,심마니,세이클럽 가입하고 발송 테스트





=================================================

회원가입 란에 메일 주소 예제가 있을 경우 카피 하는 회원 많음.

tood@toodent.com



=================================================

한글 메일 주소 종종 있음

ssss@다음.net

ssss@세이클럽.com



=================================================

회원가입 DB의 메일주소와 ID를 파일로 넣어라 !

저널링 파일 시스템이 아닐 경우 2천명 씩,

저널렁 파일 시스템일 경우는 5천명씩.



5천명의 기록을 저장한 파일 10.txt, 11.txt , 12.txt 파일을 차례로 읽어서 발송하도록 할 것 !

RAM이 허락 하고, 저널링 파일 시스템이고, 멀티플 큐 일 경우 통으로 보내도 가능

512메가나 1G 정도의 램일 경우

=================================================



웹서버 말고, 당근 별도의 메일 서버 필요



=================================================

멀티플 큐 sendmail.cf ★

저널링 파일 시스템일 경우에만 가능 !

O QueueDirectory=/var/spool/mqueue/q*





# cd /var/spool/mqueue

# mkdir q1 q2 q3 q4 q5 q6

# chown root.mail q*





# /etc/rc.d/init.d/sendmail restart





=================================================





=================================================

★ PHP 버전 최소 PHP4.2 이상



./configure시에 --enable-cli 옵션을 주어야 가능 !

PHP4.3은 기본 설치 됨 !



http://www.php.net/manual/en/features.commandline.php



rpm 4.2 버전에서 된다.



http://www.php.net/manual/en/features.commandline.php





-q             Quiet-mode.  Suppress HTTP Header output.

HTTP 헤더 출력을 억제한다.



-a 동적으로 실행- 헤더 출력 됨 !





[mailing@localhost mailing]$ php -a testx.php

Interactive mode enabled



X-Powered-By: PHP/4.2.2

Content-type: text/html



[mailing@localhost mailing]$ php testx.php

X-Powered-By: PHP/4.2.2

Content-type: text/html





쉘로 짜도 헤더 출력 됨 !





=================================================

큐 상태 보기

# mailq



메일 큐 지우기. sendmail 중지하고, /var/spool/mqueue 아래 큐 디렉토리 들어가서 rm -rf *으로 모두 지우고,

sendmail 재 시작





메일 상태 보기

# mailstat

=================================================



<b>Fatal error</b>:  Allowed memory size of 8388608 bytes exhausted (tried to allocate 262144 bytes) in

<b>/



오류



php.ini 에서 memory_limit  옵션 늘려주어야 함 !



파일 크기가 너무 클 경우에 나오는 에러 !



=================================================

mail() 사용, fsockopen() 사용 ,popen() 사용, socket_connect() 사용



메일서버가 다른 서버라면 소켓 연결 해야 함.



=================================================

다른 전략 3: 숨은 참조(BCC)를 무자게 크게 해서 보내라

전략 4: bulk_mailer 프로그램을 사용해라





=================================================





Lots of stuff to tune -



[1] Speed up your filesystem.  In fact getting yourself a set of

ramdisks (especially those new ones with battery backup) and using

them should speed things up.



[2] Multiple queues, spread across multiple spindles.  Use qtool.pl

heavily - to move outbound mail that gets delayed to backup queues -

and later to fallback hosts which will take over delivery.  Have one

general "dustbin" host as a last resort, where undeliverables

accumulate, are looked at / acted upon [to resolve stuff like

nonexistent domains which have had their MX removed, ISPs which have

dropped you into their border routers ...]



[3] Local caching nameserver



[4] FEATURE(`nocanonify') and a few other things set in your sendmail

config should also help.



[5] Serializing mail delivery, sorting it according to domain ... and

switching to sendmail 8.12.x (which supports pipelining) should also

help you a lot.



[6] Use VERP as much as possible - and split your mail functions

(outbound, inbound, bounce processing etc) across multiple machines.

Have some kind of load balancer - and make sure you process bounces at

the same (or nearly so) rate as you send out mail.  You don't do that,

you run the risk of being blocked by assorted ISPs for overloading

their mail systems with bounces.



There's lots more, but this should do for starters I guess :)



        -srs

=================================================



1:  Upgrade to sendmail-8.12.x (8.12.3 is current).  It is

    a little more efficient, because it does not fork() after

    MAIL.



2:  If you are using large mailing lists, then use the envelope

    splitting capabilities of 8.12.x



3:  Use FEATURE(`nocanonify') to reduce DNS lookups.



4:  Mount the disk partition containing /var/spool/mqueue with

    logging.  This increases solaris disk throughput.

=================================================

Thanks Claus I'm getting there but I've searched the Internet for

these defines...

ESMTP_MAILER_QGRP

confSPLIT_ACROSS_QUEUEGROUPS

etc but unfortunately found nothing.



I've read the TUNING text and the Sendmail Installation and operation

guide section 2.3.1 "Queue Groups and Queue Directories" but I'm still

puzzled.



Each individual address has its own domain i.e. each mail is to a

separate server (500 servers) so I cannot split the queue depending on

the domains.



I've created 4 queue dirs mqueue/q0 mqueue/q1 mqueue/q2 mqueue/q3 and

utilise these already using simply:

define(`QUEUE_DIR',`/var/spool/mqueue/q*')dnl

Indeed by default sendmail places mails randomly into a queue and from

the section 2.3.1 I understand this is the default "mqueue".



How do I define that this default "mqueue" should split large mails

with more than 10 recipients (r=10), what statement ?

and will it then automatically split such mails over all 4 queues ?



Thanks in advance and I hope this will lay down answers for future

Internet searches :-)



=================================================

추천 사이트

http://www.shub-internet.org/brad/papers/sendmail-tuning/



http://tunelinux.pe.kr/sysadmin/iskim/linux-window-7.html

=================================================

갑자기 실행시간 에러 메시지가..

Maximum execution time of 30 seconds exceeded in <b>/home/mailing/homepage/mailing/mail_sender3.php</b>

on line <b>27</b><br />



mail() 함수에서 발생한 오류



2시간만에...흠...ㅋㅋ



메일 큐에 1000개가 쌓이니까 더이상 전송이 안되는 군...ㅋㅋㅋ



1시간이 넘었는데 메일큐의 메일 들이 안갈 경우 모두 삭제 !



메일을 6천개 정도 테스트로 발송 한후 큐에 1000개 정도 쌓일 경우

메일 발송 파일을 6천개로 분리하는 것이..



O MaxQueueRunSize=10000 1만이라고 해도, 큐에 1천개가 쌓일 경우 버벅거림.

시스템이 워낙 꼬져서리...--; 시스템 좋으면 문제 없음.



그러나 잘못된 메일주소 거나, 메일박스가 꽉찼을 경우 문제됨.

정상적인 메일 주소일 경우 5천통 보내는데 1시간 걸린다면,

잘못된 메일 주소가 2-30%정도만 있어도 2시간 정도 걸림...--;





자신의 메일주소로 1-2만개 정도 메일링 주소를 만들고,  

발송테스트 해서 메일큐에 얼마나 쌓이는지 반드시 테스트



1시간이 지났는데도 메일을 모두 발송하지 못했을 경우

메일큐에 많이 남았을 경우

메일링 주소 파일을 더 적게 생성 해야 함.



우왕...짭 128 메가 서버라 5천개 발송하는데 2시간..

1천개는 큐에...미치..



=================================================

mime 리턴패스 설정



$from="help@tood.net";



$headers  = "MIME-Version: 1.0\r\n";

$headers .= "Content-type: text/html; charset=euc-kr\r\n";

$headers .= "From: tood <$from>\r\n";

mail($to, $subject, $message, $headers,"-f$from");



=================================================



rm -rf /var/spool/mqueue/q*/*



/etc/rc.d/init.d/sendmail restart





=================================================

MaxDaemonChildren RefuseLA



ps -aux |grep sendmail

ps -aux |grep php

[출처] 웹디황용

"쇼핑몰·홈페이지·오픈마켓
블로그·페이스북·이메일 등의 각종 마케팅 글쓰기,
각종 광고, 영업, 판매, 제안서, 전단지
반응율 3배×10배 이상 높이는 마법의 8단계 공식"
자세히보기

Comments

번호 제목 글쓴이 날짜 조회
2835 [MSSQL]데이터베이스 옵션 설정 99 단국강토 01.12 3053
2834 여러객체를 for 문 돌리며 사용 99 단국강토 02.19 3052
2833 씬시티 영화 처럼 특정색 강조하기 10 액션쟁이 01.07 3050
2832 T-SQL: Parameter Sniffing 쿼리 튜닝 99 단국강토 01.05 3047
2831 vmware에 설치한 페도라코어5에 vmware tool 설치하기 99 단국강토 01.05 3046
2830 SQL : 집계함수 : 집계함수. 13 김영철 01.23 3045
2829 [AJAX] DOMDocument 에서 selectSingleNode 을 이용한 XML 노드 (Node) 찾기 99 단국강토 12.30 3045
2828 테그의 기본 99 단국강토 02.04 3043
2827 동영상 그림크기조절 99 단국강토 12.30 3042
2826 php전역변수 13 김영철 01.14 3041
2825 MSSQL 기본값 13 김영철 01.24 3040
2824 음악 태그 사운드 태그 댓글1 M 최고의하루 12.24 3039
2823 리눅스의 기본 명령어 99 단국강토 12.30 3039
2822 오라클 캐릭터 셋 변경 M 최고의하루 01.12 3039
2821 DBMS에 따른 날짜포맷 변환 99 단국강토 01.07 3038
2820 포토샵-만화처럼 보이게 하기(신시티스타일) 10 액션쟁이 01.07 3035
2819 [CSS]스타일시트 {속성:값}의 모든 것 99 단국강토 02.03 3035
2818 MovieClip.attachMovie 99 단국강토 02.05 3034
2817 MySQL에서 외래키 설정하기 13 김영철 01.29 3034
2816 일본어로 된 웹을 한글로 즐기기 99 단국강토 01.06 3033
2815 <HTML TIP> 스크롤바, 링크주변 점선 제거, IFrame속성.. 99 단국강토 02.03 3030
2814 버튼 미디어 플래이어를 구현해 보자 99 단국강토 02.19 3030
2813 문자열중 숫자만 출력하기 13 김영철 01.14 3030
2812 php 파일 업, 다운로드 13 김영철 01.13 3028
2811 BLOCKQUOTE TAG 99 단국강토 01.20 3027
2810 php 대용량 메일 13 김영철 01.13 3027
2809 [정보] EditPlus에서 BOM 문제 해결법 13 김영철 01.14 3025
열람중 php 대용량 메일 13 김영철 01.13 3025
2807 cascasde(연속동작) 13 김영철 01.23 3025
2806 E execCommand() 의 명령어 목록 | JavaScript 99 단국강토 01.30 3024
마케팅
특별 마케팅자료
다운로드 마케팅자료
창업,경영
기획,카피,상품전략
동기부여,성취