: 이건 제가 스스로 창작한것이 아니고,
: 퍼뜩이 라는 분이 C로 만든 소스를 보고 다시 파이썬으로 구현한
: 것입니다.
: 그분은 CGI 버젼으로 만들었는데, 소스가 상당히 깁니다.
: 근데 제가 만든 파이썬버젼은 50줄도 안된답니다. 히히..
: 원본 C 소스는 http://cafe.sarang.net 에서 구경하실수 있구요.
: 이걸 만드신 분은 이건 정식으로 허가 받지 않은 방법이라서
: 과다하게 사용하면 통신업체에서 포트를 막을지도 모른 다고 하네요..
: 전 011, 016, 017 이 되는것을 확인했구요, 나머지는 아직 테스트
: 안해봤네요 ^^
: 소스에서 USER 부분만 고치고 바로 사용하세요...
:
:
: #!/usr/bin/env python
:
: import socket
: import string
:
: #---------------------- Please Change This -------------------------#
: USER = '아무개' # 자신의 이멜 주소를 적으세요.
: #-------------------------------------------------------------------#
:
: HOST = ['203.236.1.18', '128.134.98.134', '203.226.207.228',
: '210.112.11.51', '210.124.165.3'];
: PORT = 25
:
: def maketo(phone_number):
: co = phone_number[:3]
: if co == '011':
: toaddr = "%s at cyber.sktelecom.co.kr" % phone_number
: host = HOST[0]
: elif co == '016':
: toaddr = "%s at sms.n016.co.kr" % phone_number
: host = HOST[1]
: elif co == '017':
: toaddr = "%s at sms.shinsegi.com" % phone_number
: host = HOST[2]
: elif co == '018':
: toaddr = "m%s at hansolm.com" % phone_number
: host = HOST[3]
: elif co == '019':
: toaddr = "%s at 019pcs.lgtel.co.kr" % phone_number
: host = HOST[4]
: return toaddr, host
:
: def send(phone_number, msg):
: toaddr, host = maketo(phone_number)
: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
: s.connect((host, PORT))
: s.send("HELO")
: print s.recv(1024)
: s.send("mail from: <%s>" % USER)
: print s.recv(1024)
: s.send("rcpt to: <%s>" % toaddr)
: print s.recv(1024)
: s.send("data")
: print s.recv(1024)
: s.send("Subject:%s" % msg)
: print s.recv(1024)
: s.send(".")
: print s.recv(1024)
: s.send("quit")
: print s.recv(1024)
: s.close()
:
: if __name__ == "__main__":
: phone_number = string.strip(raw_input("핸드폰 번호 (ex: 01198765432):"))
: print "메세지 입력. '#'표시가 있는곳 까지 문자를 입력하세요."
: print "#"*80
: msg = string.strip(raw_input())
: send(phone_number, msg)
올려주신 소스 감사히 보았습니다.
요건 제가 그냥 php cgi 버젼으루 다시 바꿔 봤어요.. ^^
<?
$HOST=array("203.236.1.18", "128.134.98.134", "203.226.207.228","210.112.11.51", "210.124.165.3");
$PORT=25;
function maketo($phone_number){
global $HOST;
$co=substr($phone_number,0,3);
if( $co == '011'){
$ret[toaddr] = "$phone_number at cyber.sktelecom.co.kr";
$ret[host]=$HOST[0];
}
elseif ($co == '106'){
$ret[toaddr] = "$phone_number at sms.n106.co.kr" ;
$ret[host]=$HOST[1];
}
elseif ($co == '017'){
$ret[toaddr] = "$phone_number at sms.shinsegi.com" ;
$ret[host]=$HOST[2];
}
elseif ($co == '018'){
$ret[toaddr] = "m$phone_number at hansolm.com" ;
$ret[host]=$HOST[3];
}
elseif ($co == '019'){
$ret[toaddr] = "$phone_number at 019pcs.lgtel.co.kr" ;
$ret[host]=$HOST[4];
}
return $ret;
}
function send($sender,$phone_number,$msg){
global $PORT;
$ret=maketo($phone_number);
$toaddr=$ret[toaddr];
$host=$ret[host];
$fp=fsockopen($host,$PORT);
fputs($fp,"HELO");
$print=fgets($fp,1024);
fputs($fp,"mail from: <$sender>" );
$print.=fgets($fp,1024);
fputs($fp,"rcpt to: <$toaddr>");
$print.=fgets($fp,1024);
fputs($fp,"data");
$print.=fgets($fp,1024);
fputs($fp,"Subject:$msg");
$print.=fgets($fp,1024);
fputs($fp,".");
$print.=fgets($fp,1024);
fputs($fp,"quit");
$print.=fgets($fp,1024);
fclose($fp);
}
// ex) send("lizo","0173337777","hello");
send($sender,$phone_number,$msg);
?>--이 곳에 서명을 적어주십시오.
--a