RadarURL
Skip to content
조회 수 3938 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
출처: http://www.linuxquestions.org/questions/showthread.php?t=359033
        http://pear.php.net/package/Mail
아래 소스는
http://www.linuxquestions.org/questions/showthread.php?t=359033
에서 가져 왔고
Mail_smtp 클래스는
http://pear.php.net/package/Mail
에서 받으시면 됩니다.

<?php

include('Mail/smtp.php');

class MailHandler{
var $params = null;
var $mail_object = null;
var $recipients = null;
var $headers = null;
var $body = "";

function MailHandler($host, $port, $auth, $username, $password, $persist) {
$this->params["host"] = $host;
$this->params["port"] = $port;
$this->params["auth"] = $auth;
$this->params["username"] = $username;
$this->params["password"] = $password;
$this->params["persist"] = $persist;

// Create the mail object using the Mail::factory method
//$this->mail_object =& Mail::factory('smtp', $this->params);
$this->mail_object = new Mail_smtp($this->params);
}

function createFrom($email){
$this->headers['From'] = $email;
}

function createTo($email){
$this->headers['To'] = $email;
$this->recipients = array($email);
}

function createCC($email){
$this->headers['Cc'] = $email;
}

function createBCC($email){
$this->headers['Bcc'] = $email;
}

function createSubject($sub){
$this->headers['Subject'] = $sub;
}

function createBody($body){
$this->body=$body;
}

function sendMail(){
if ($this->mail_object->send($this->recipients, $this->headers, $this->body)) {
return true;
}
else{
return false;
}
}
}


$smtpserver_host = "localhost"; // The server to connect. Default is localhost
$smtpserver_Port = 25; // The port to connect. Default is 25
$smtpserver_auth = FALSE; // Whether or not to use SMTP authentication. Default is FALSE
$smtpserver_username = "username"; // The username to use for SMTP authentication.
$smtpserver_password = "password"; // The password to use for SMTP authentication.
$smtpserver_persist = FALSE; // Indicates whether or not the SMTP connection should persist over multiple calls to the send() method.
$mailhandler=new MailHandler($smtpserver_host, $smtpserver_Port, $smtpserver_auth, $smtpserver_username, $smtpserver_password, $smtpserver_persist);

$mailhandler->createTo("toaddress");
$mailhandler->createFrom("fromaddress");
$mailhandler->createSubject("subject");
$mailhandler->createBody("body");

if($mailhandler->sendMail()){
echo "Mail sent.n";
}
else{
echo "Error sending mail!n";
}

?>

출처 : http://www.sir.co.kr/bbs/board.php?bo_table=pl_php&wr_id=333&page=4
?

List of Articles
번호 제목 글쓴이 날짜 조회 수
76 숨겨진 진주, ‘공개 네트워크 툴’을 찾아라 JaeSoo 2004.07.19 893
75 Modelling and Simulation Resources on the Internet JaeSoo 2005.05.07 5065
74 페이지로딩속도가 느릴 경우 (3초이상) JaeSoo 2005.12.28 3973
73 메일 발송시 리턴메일 메시지 JaeSoo 2007.06.05 3620
» smtp를 이용하여 mail 보내기 (pear 사용) JaeSoo 2007.06.07 3938
71 초고속선도망(KOREN) 사업 보고서 JaeSoo 2007.12.06 4543
70 `IPv6` 9월 부터 시범서비스 JaeSoo 2007.12.07 3623
69 Ten things Your IT department won't tell you (IT 부서가 당신에게 말해주지 않는 10가지) JaeSoo 2007.12.28 4144
68 자가전기통신설비(자가망)관련 법령 JaeSoo 2007.12.28 4941
67 정보통신기반보호법(요약) 및 검토 JaeSoo 2007.12.28 5066
66 조기경보시스템(1)-조기경보 시스템의 개요 JaeSoo 2008.01.28 3802
65 조기경보시스템(2)-조기경보 시스템의 기술 동향 JaeSoo 2008.01.28 3625
64 조기경보시스템(3)-조기경보 시스템(Early Warning System)의 국내외 구축·운영 사례 JaeSoo 2008.01.28 3817
63 초고속 정보통신 인증제, 홈네트워크 인증제 JaeSoo 2008.02.25 3748
62 무료 PC 원격제어 JaeSoo 2008.07.02 4326
61 인터넷 친구를 만들거나 비지니스 인맥을 만드는 웹어플리케이션, SNS JaeSoo 2008.07.23 3626
60 Openet JaeSoo 2009.09.29 3746
59 윈도우즈에서 Squid 프락시 서버 설치 JaeSoo 2009.10.05 3904
58 네트워크 충돌검색 [nbtstat]명령어 JaeSoo 2009.10.05 4833
57 듀얼 WAN 사용 시 대역폭 문제 JaeSoo 2010.01.22 6235
Board Pagination Prev 1 2 3 4 Next
/ 4

PageViews   Today : 11150 Yesterday : 5037 Total : 21967202  /  Counter Status   Today : 10787 Yesterday : 4602 Total : 1193510

Edited by JAESOO

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소