출처: 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>
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 830 |
|
19년 전 | 2199 | |
| 829 |
|
19년 전 | 1941 | |
| 828 |
|
19년 전 | 1823 | |
| 827 |
|
19년 전 | 1660 | |
| 826 |
|
19년 전 | 1858 | |
| 825 |
|
19년 전 | 1908 | |
| 824 |
|
19년 전 | 1963 | |
| 823 |
|
19년 전 | 2699 | |
| 822 |
|
19년 전 | 5336 | |
| 821 |
|
19년 전 | 1732 | |
| 820 |
|
19년 전 | 1588 | |
| 819 |
|
19년 전 | 1453 | |
| 818 |
|
19년 전 | 1614 | |
| 817 |
|
19년 전 | 1538 | |
| 816 |
|
19년 전 | 1461 | |
| 815 |
|
19년 전 | 1471 | |
| 814 |
|
19년 전 | 1389 | |
| 813 |
|
19년 전 | 1459 | |
| 812 | 19년 전 | 2832 | ||
| 811 |
pearly
|
19년 전 | 3848 | |
| 810 |
pearly
|
19년 전 | 5228 | |
| 809 |
|
19년 전 | 1390 | |
| 808 |
pearly
|
19년 전 | 4547 | |
| 807 | 19년 전 | 2989 | ||
| 806 |
|
19년 전 | 1509 | |
| 805 |
|
19년 전 | 2701 | |
| 804 |
|
19년 전 | 3632 | |
| 803 |
|
19년 전 | 1820 | |
| 802 |
|
19년 전 | 3798 | |
| 801 |
|
19년 전 | 1893 | |
| 800 | 19년 전 | 3779 | ||
| 799 | 19년 전 | 3449 | ||
| 798 | 19년 전 | 4215 | ||
| 797 | 19년 전 | 4086 | ||
| 796 |
|
19년 전 | 1903 | |
| 795 |
|
19년 전 | 1865 | |
| 794 | 19년 전 | 4284 | ||
| 793 | 19년 전 | 2680 | ||
| 792 | 19년 전 | 2555 | ||
| 791 | 19년 전 | 2413 | ||
| 790 | 19년 전 | 1993 | ||
| 789 | 19년 전 | 2601 | ||
| 788 | 19년 전 | 2218 | ||
| 787 | 19년 전 | 1860 | ||
| 786 | 19년 전 | 1981 | ||
| 785 | 19년 전 | 1454 | ||
| 784 |
|
19년 전 | 1702 | |
| 783 | 19년 전 | 2850 | ||
| 782 |
|
19년 전 | 1974 | |
| 781 | 19년 전 | 3261 | ||
| 780 | 19년 전 | 3173 | ||
| 779 |
|
19년 전 | 2256 | |
| 778 |
|
19년 전 | 1810 | |
| 777 | 19년 전 | 2852 | ||
| 776 | 19년 전 | 2917 | ||
| 775 | 19년 전 | 4033 | ||
| 774 |
|
19년 전 | 2000 | |
| 773 | 19년 전 | 2634 | ||
| 772 | 19년 전 | 2351 | ||
| 771 | 19년 전 | 3481 | ||
| 770 |
|
19년 전 | 1450 | |
| 769 | 19년 전 | 1514 | ||
| 768 | 19년 전 | 1788 | ||
| 767 | 19년 전 | 2211 | ||
| 766 | 19년 전 | 1841 | ||
| 765 | 19년 전 | 1702 | ||
| 764 |
|
19년 전 | 2125 | |
| 763 |
|
19년 전 | 2236 | |
| 762 |
|
19년 전 | 4971 | |
| 761 | 19년 전 | 2340 | ||
| 760 |
|
19년 전 | 3202 | |
| 759 | 19년 전 | 2653 | ||
| 758 |
|
19년 전 | 2414 | |
| 757 | 19년 전 | 4711 | ||
| 756 | 19년 전 | 2581 | ||
| 755 |
|
19년 전 | 2425 | |
| 754 |
|
19년 전 | 1975 | |
| 753 |
|
19년 전 | 1759 | |
| 752 |
pearly
|
19년 전 | 3379 | |
| 751 | 19년 전 | 2358 | ||
| 750 |
|
19년 전 | 6173 | |
| 749 | 19년 전 | 2047 | ||
| 748 |
|
19년 전 | 1919 | |
| 747 |
|
19년 전 | 2716 | |
| 746 |
|
19년 전 | 1827 | |
| 745 | 19년 전 | 2289 | ||
| 744 | 19년 전 | 2126 | ||
| 743 |
|
19년 전 | 3580 | |
| 742 | 19년 전 | 2594 | ||
| 741 | 19년 전 | 2756 | ||
| 740 |
|
19년 전 | 4380 | |
| 739 | 19년 전 | 3560 | ||
| 738 |
|
19년 전 | 2315 | |
| 737 | 19년 전 | 4325 | ||
| 736 | 19년 전 | 3286 | ||
| 735 |
홀로남은자
|
19년 전 | 4162 | |
| 734 |
홀로남은자
|
19년 전 | 2034 | |
| 733 |
홀로남은자
|
19년 전 | 2240 | |
| 732 | 19년 전 | 2149 | ||
| 731 | 19년 전 | 3375 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기