별도의 메일서버 없이 gmail 을 이용하여 메일 보내는 php 소스 입니다.
class download : http://sourceforge.net/projects/xpertmailer
클래스 파일을 다운로드 받아 압축을 풀고 /EXAMPLES/ 폴더에서 샘플을 확인할수
있고 mail-relay.php 파일에 메일 전송 샘플소스가 포함되어 있으니 참고 하시기 바랍니다.
From('username@gmail.com'); // add to address $m->AddTo('client@destination.net'); // set subject $m->Subject('Hello World!'); // set HTML message $m->Html('HTML message.'); // connect to MTA server 'smtp.gmail.com' port '465' via SSL ('tls' encryption) // with authentication: 'username@gmail.com'/'password' // set the connection timeout to 10 seconds, the name of your host 'localhost' and the authentication method to 'plain' // make sure you have OpenSSL module (extension) enable on your php configuration $c = $m->Connect('smtp.gmail.com', 465, 'username@gmail.com', 'password', 'tls', 10, 'localhost', null, 'plain') or die(print_r($m->Result)); // send mail relay using the '$c' resource connection echo $m->Send($c) ? 'Mail sent !' : 'Error !'; // disconnect from server $m->Disconnect(); // optional for debugging ---------------- echo '
'; // print History print_r($m->History); // calculate time list($tm1, $ar1) = each($m->History[0]); list($tm2, $ar2) = each($m->History[count($m->History)-1]); echo 'The process took: '.(floatval($tm2)-floatval($tm1)).' seconds.'; ?>
소스에서 username@gmail.com , password 부분을 자신의 gmail계정으로 수정하고
from, to 정보를 수정하면 테스트메일을 받아 볼 수 있다.
'프로그램 > 기타 레퍼런스' 카테고리의 다른 글
MS-SQL 인덱스 [클러스터형 과 넌클러스터형]의 차이점 (0) | 2011.01.25 |
---|---|
Twitter, facebook, google talk :: API 참고사이트 (0) | 2011.01.21 |
gmail smtp를 이용하여 메일발송 하는 php 소스 (0) | 2011.01.14 |
구글크롬 확장프로그램 개발 도~전 : Get started: 개발자를 위한 정보 (3) | 2010.12.31 |
RJ45 케이블 결선 방법 - 랜 케이블 만들기 (0) | 2010.12.23 |
ASCII 코드표 0~255 [DEC, OCT, HEX, BIN, HTML] (5) | 2010.11.30 |