출처: 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";
}
?><div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:12:10 PHP & HTML에서 이동 됨]</div>
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";
}
?><div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:12:10 PHP & HTML에서 이동 됨]</div>
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8230 | 9년 전 | 118 | ||
| 8229 | 9년 전 | 115 | ||
| 8228 |
커네드커네드
|
9년 전 | 157 | |
| 8227 | 9년 전 | 201 | ||
| 8226 | 9년 전 | 212 | ||
| 8225 | 9년 전 | 194 | ||
| 8224 | 9년 전 | 185 | ||
| 8223 | 9년 전 | 165 | ||
| 8222 |
|
9년 전 | 242 | |
| 8221 | 9년 전 | 148 | ||
| 8220 | 9년 전 | 185 | ||
| 8219 | 9년 전 | 142 | ||
| 8218 | 9년 전 | 190 | ||
| 8217 |
star3840
|
9년 전 | 160 | |
| 8216 | 9년 전 | 229 | ||
| 8215 | 9년 전 | 180 | ||
| 8214 | 9년 전 | 277 | ||
| 8213 | 9년 전 | 227 | ||
| 8212 | 9년 전 | 143 | ||
| 8211 | 9년 전 | 316 | ||
| 8210 | 9년 전 | 324 | ||
| 8209 | 9년 전 | 396 | ||
| 8208 | 9년 전 | 287 | ||
| 8207 | 9년 전 | 289 | ||
| 8206 |
|
9년 전 | 245 | |
| 8205 | 9년 전 | 228 | ||
| 8204 | 9년 전 | 197 | ||
| 8203 | 9년 전 | 274 | ||
| 8202 | 9년 전 | 193 | ||
| 8201 | 9년 전 | 239 | ||
| 8200 | 9년 전 | 236 | ||
| 8199 | 9년 전 | 258 | ||
| 8198 | 9년 전 | 226 | ||
| 8197 | 9년 전 | 216 | ||
| 8196 | 9년 전 | 614 | ||
| 8195 | 9년 전 | 217 | ||
| 8194 | 9년 전 | 330 | ||
| 8193 | 9년 전 | 228 | ||
| 8192 | 9년 전 | 253 | ||
| 8191 | 9년 전 | 207 | ||
| 8190 | 9년 전 | 202 | ||
| 8189 | 9년 전 | 258 | ||
| 8188 | 9년 전 | 194 | ||
| 8187 | 9년 전 | 195 | ||
| 8186 | 9년 전 | 199 | ||
| 8185 | 9년 전 | 367 | ||
| 8184 | 9년 전 | 153 | ||
| 8183 | 9년 전 | 378 | ||
| 8182 | 9년 전 | 231 | ||
| 8181 | 9년 전 | 190 | ||
| 8180 | 9년 전 | 767 | ||
| 8179 | 9년 전 | 538 | ||
| 8178 | 9년 전 | 384 | ||
| 8177 |
kiplayer
|
9년 전 | 392 | |
| 8176 | 9년 전 | 422 | ||
| 8175 | 9년 전 | 299 | ||
| 8174 | 9년 전 | 300 | ||
| 8173 | 9년 전 | 396 | ||
| 8172 | 9년 전 | 259 | ||
| 8171 | 9년 전 | 232 | ||
| 8170 | 9년 전 | 355 | ||
| 8169 |
커네드커네드
|
9년 전 | 309 | |
| 8168 | 9년 전 | 380 | ||
| 8167 | 9년 전 | 375 | ||
| 8166 | 9년 전 | 282 | ||
| 8165 | 9년 전 | 223 | ||
| 8164 | 9년 전 | 363 | ||
| 8163 | 9년 전 | 350 | ||
| 8162 | 9년 전 | 357 | ||
| 8161 | 9년 전 | 369 | ||
| 8160 |
|
9년 전 | 563 | |
| 8159 | 9년 전 | 506 | ||
| 8158 | 9년 전 | 314 | ||
| 8157 | 9년 전 | 429 | ||
| 8156 | 9년 전 | 312 | ||
| 8155 | 9년 전 | 306 | ||
| 8154 |
00년생용띠
|
9년 전 | 645 | |
| 8153 | 9년 전 | 284 | ||
| 8152 |
|
9년 전 | 470 | |
| 8151 | 9년 전 | 465 | ||
| 8150 | 9년 전 | 572 | ||
| 8149 |
Jangfolk
|
9년 전 | 419 | |
| 8148 | 9년 전 | 237 | ||
| 8147 | 9년 전 | 439 | ||
| 8146 | 9년 전 | 514 | ||
| 8145 | 9년 전 | 465 | ||
| 8144 | 9년 전 | 426 | ||
| 8143 | 9년 전 | 258 | ||
| 8142 | 9년 전 | 485 | ||
| 8141 | 9년 전 | 431 | ||
| 8140 | 9년 전 | 978 | ||
| 8139 | 9년 전 | 330 | ||
| 8138 |
전갈자리남자
|
9년 전 | 439 | |
| 8137 | 9년 전 | 472 | ||
| 8136 | 9년 전 | 803 | ||
| 8135 |
|
9년 전 | 840 | |
| 8134 |
PlayPixel
|
9년 전 | 578 | |
| 8133 |
|
9년 전 | 496 | |
| 8132 | 9년 전 | 517 | ||
| 8131 | 9년 전 | 880 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기