출처: 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>
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7830 | 10년 전 | 460 | ||
| 7829 |
|
10년 전 | 642 | |
| 7828 | 10년 전 | 570 | ||
| 7827 | 10년 전 | 470 | ||
| 7826 | 10년 전 | 494 | ||
| 7825 | 10년 전 | 523 | ||
| 7824 | 10년 전 | 485 | ||
| 7823 | 10년 전 | 426 | ||
| 7822 | 10년 전 | 400 | ||
| 7821 | 10년 전 | 347 | ||
| 7820 | 10년 전 | 368 | ||
| 7819 |
|
10년 전 | 767 | |
| 7818 | 10년 전 | 425 | ||
| 7817 | 10년 전 | 604 | ||
| 7816 | 10년 전 | 443 | ||
| 7815 | 10년 전 | 636 | ||
| 7814 | 10년 전 | 477 | ||
| 7813 | 10년 전 | 433 | ||
| 7812 | 10년 전 | 440 | ||
| 7811 | 10년 전 | 419 | ||
| 7810 | 10년 전 | 615 | ||
| 7809 | 10년 전 | 552 | ||
| 7808 | 10년 전 | 430 | ||
| 7807 | 10년 전 | 441 | ||
| 7806 |
프로그래머7
|
10년 전 | 1363 | |
| 7805 | 10년 전 | 1305 | ||
| 7804 |
zahir1312
|
10년 전 | 805 | |
| 7803 |
|
10년 전 | 1405 | |
| 7802 | 10년 전 | 505 | ||
| 7801 | 10년 전 | 883 | ||
| 7800 | 10년 전 | 1110 | ||
| 7799 | 10년 전 | 594 | ||
| 7798 | 10년 전 | 541 | ||
| 7797 | 10년 전 | 561 | ||
| 7796 | 10년 전 | 395 | ||
| 7795 | 10년 전 | 547 | ||
| 7794 | 10년 전 | 589 | ||
| 7793 | 10년 전 | 1088 | ||
| 7792 | 10년 전 | 510 | ||
| 7791 | 10년 전 | 607 | ||
| 7790 | 10년 전 | 531 | ||
| 7789 |
fbastore
|
10년 전 | 1482 | |
| 7788 | 10년 전 | 587 | ||
| 7787 | 10년 전 | 445 | ||
| 7786 | 10년 전 | 653 | ||
| 7785 | 10년 전 | 624 | ||
| 7784 | 10년 전 | 689 | ||
| 7783 | 10년 전 | 509 | ||
| 7782 | 10년 전 | 532 | ||
| 7781 | 10년 전 | 936 | ||
| 7780 | 10년 전 | 846 | ||
| 7779 | 10년 전 | 799 | ||
| 7778 | 10년 전 | 390 | ||
| 7777 | 10년 전 | 501 | ||
| 7776 | 10년 전 | 498 | ||
| 7775 | 10년 전 | 435 | ||
| 7774 | 10년 전 | 647 | ||
| 7773 | 10년 전 | 401 | ||
| 7772 | 10년 전 | 774 | ||
| 7771 | 10년 전 | 431 | ||
| 7770 | 10년 전 | 672 | ||
| 7769 | 10년 전 | 434 | ||
| 7768 | 10년 전 | 653 | ||
| 7767 | 10년 전 | 1206 | ||
| 7766 | 10년 전 | 534 | ||
| 7765 | 10년 전 | 593 | ||
| 7764 |
잘살아보자
|
10년 전 | 453 | |
| 7763 |
|
10년 전 | 1500 | |
| 7762 |
Tosea
|
10년 전 | 1087 | |
| 7761 | 10년 전 | 692 | ||
| 7760 |
잘살아보자
|
10년 전 | 760 | |
| 7759 |
잘살아보자
|
10년 전 | 598 | |
| 7758 |
잘살아보자
|
10년 전 | 658 | |
| 7757 | 10년 전 | 1282 | ||
| 7756 |
ITBANK
|
10년 전 | 1290 | |
| 7755 | 10년 전 | 1945 | ||
| 7754 | 10년 전 | 1102 | ||
| 7753 | 10년 전 | 922 | ||
| 7752 | 10년 전 | 1421 | ||
| 7751 |
잘살아보자
|
10년 전 | 580 | |
| 7750 |
잘살아보자
|
10년 전 | 508 | |
| 7749 |
잘살아보자
|
10년 전 | 529 | |
| 7748 |
잘살아보자
|
10년 전 | 559 | |
| 7747 |
잘살아보자
|
10년 전 | 637 | |
| 7746 |
잘살아보자
|
10년 전 | 699 | |
| 7745 |
잘살아보자
|
10년 전 | 948 | |
| 7744 |
잘살아보자
|
10년 전 | 441 | |
| 7743 | 10년 전 | 971 | ||
| 7742 |
starbros
|
10년 전 | 865 | |
| 7741 |
잘살아보자
|
10년 전 | 707 | |
| 7740 |
잘살아보자
|
10년 전 | 595 | |
| 7739 |
잘살아보자
|
10년 전 | 487 | |
| 7738 |
잘살아보자
|
10년 전 | 562 | |
| 7737 |
잘살아보자
|
10년 전 | 541 | |
| 7736 |
잘살아보자
|
10년 전 | 561 | |
| 7735 |
잘살아보자
|
10년 전 | 897 | |
| 7734 |
잘살아보자
|
10년 전 | 454 | |
| 7733 |
잘살아보자
|
10년 전 | 564 | |
| 7732 |
잘살아보자
|
10년 전 | 731 | |
| 7731 |
잘살아보자
|
10년 전 | 653 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기