출처: 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>
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 230 | 20년 전 | 2089 | ||
| 229 | 20년 전 | 3148 | ||
| 228 | 20년 전 | 3341 | ||
| 227 | 20년 전 | 2417 | ||
| 226 | 20년 전 | 5497 | ||
| 225 | 20년 전 | 2537 | ||
| 224 | 20년 전 | 2981 | ||
| 223 | 20년 전 | 4212 | ||
| 222 | 20년 전 | 2612 | ||
| 221 | 20년 전 | 2302 | ||
| 220 | 20년 전 | 3690 | ||
| 219 | 20년 전 | 2084 | ||
| 218 | 20년 전 | 3586 | ||
| 217 | 20년 전 | 2496 | ||
| 216 | 20년 전 | 2935 | ||
| 215 | 20년 전 | 2245 | ||
| 214 | 20년 전 | 3352 | ||
| 213 | 20년 전 | 2933 | ||
| 212 | 20년 전 | 3073 | ||
| 211 | 20년 전 | 2160 | ||
| 210 | 20년 전 | 1930 | ||
| 209 | 20년 전 | 2383 | ||
| 208 | 20년 전 | 2009 | ||
| 207 | 20년 전 | 1692 | ||
| 206 | 20년 전 | 1866 | ||
| 205 | 20년 전 | 3962 | ||
| 204 | 20년 전 | 1684 | ||
| 203 | 20년 전 | 2024 | ||
| 202 | 20년 전 | 2367 | ||
| 201 | 20년 전 | 1840 | ||
| 200 | 20년 전 | 2970 | ||
| 199 | 20년 전 | 2013 | ||
| 198 | 20년 전 | 2097 | ||
| 197 | 20년 전 | 3669 | ||
| 196 | 20년 전 | 3008 | ||
| 195 | 20년 전 | 2119 | ||
| 194 | 20년 전 | 10271 | ||
| 193 | 20년 전 | 2263 | ||
| 192 | 20년 전 | 1616 | ||
| 191 | 20년 전 | 2679 | ||
| 190 | 20년 전 | 2300 | ||
| 189 | 20년 전 | 1702 | ||
| 188 | 20년 전 | 1504 | ||
| 187 | 20년 전 | 1923 | ||
| 186 | 20년 전 | 1752 | ||
| 185 | 20년 전 | 1795 | ||
| 184 | 20년 전 | 2380 | ||
| 183 | 20년 전 | 1590 | ||
| 182 | 20년 전 | 1498 | ||
| 181 | 20년 전 | 1639 | ||
| 180 | 20년 전 | 2737 | ||
| 179 | 20년 전 | 1825 | ||
| 178 | 20년 전 | 1875 | ||
| 177 | 20년 전 | 2002 | ||
| 176 | 20년 전 | 1812 | ||
| 175 | 20년 전 | 1878 | ||
| 174 | 20년 전 | 1711 | ||
| 173 | 20년 전 | 2070 | ||
| 172 | 20년 전 | 1795 | ||
| 171 | 20년 전 | 2578 | ||
| 170 | 20년 전 | 2297 | ||
| 169 | 20년 전 | 2573 | ||
| 168 | 20년 전 | 1511 | ||
| 167 | 20년 전 | 1599 | ||
| 166 | 20년 전 | 2174 | ||
| 165 | 20년 전 | 1658 | ||
| 164 | 20년 전 | 3791 | ||
| 163 | 20년 전 | 2688 | ||
| 162 | 20년 전 | 2109 | ||
| 161 | 20년 전 | 2819 | ||
| 160 | 20년 전 | 1756 | ||
| 159 | 20년 전 | 1635 | ||
| 158 | 20년 전 | 2587 | ||
| 157 | 20년 전 | 1514 | ||
| 156 | 20년 전 | 1774 | ||
| 155 | 20년 전 | 3248 | ||
| 154 | 20년 전 | 1921 | ||
| 153 | 20년 전 | 1636 | ||
| 152 | 20년 전 | 4974 | ||
| 151 | 20년 전 | 4596 | ||
| 150 | 20년 전 | 3537 | ||
| 149 | 20년 전 | 3816 | ||
| 148 | 20년 전 | 7099 | ||
| 147 | 20년 전 | 3569 | ||
| 146 | 20년 전 | 2647 | ||
| 145 | 20년 전 | 2640 | ||
| 144 | 20년 전 | 7177 | ||
| 143 | 20년 전 | 4623 | ||
| 142 | 20년 전 | 1909 | ||
| 141 | 20년 전 | 3264 | ||
| 140 | 20년 전 | 1986 | ||
| 139 | 20년 전 | 1614 | ||
| 138 | 20년 전 | 2331 | ||
| 137 | 20년 전 | 1805 | ||
| 136 | 20년 전 | 1471 | ||
| 135 | 20년 전 | 1810 | ||
| 134 | 20년 전 | 2989 | ||
| 133 | 20년 전 | 2472 | ||
| 132 | 20년 전 | 1714 | ||
| 131 | 20년 전 | 1666 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기