출처: 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년 전 | 2186 | |
| 829 |
|
19년 전 | 1920 | |
| 828 |
|
19년 전 | 1809 | |
| 827 |
|
19년 전 | 1655 | |
| 826 |
|
19년 전 | 1850 | |
| 825 |
|
19년 전 | 1890 | |
| 824 |
|
19년 전 | 1946 | |
| 823 |
|
19년 전 | 2687 | |
| 822 |
|
19년 전 | 5317 | |
| 821 |
|
19년 전 | 1723 | |
| 820 |
|
19년 전 | 1574 | |
| 819 |
|
19년 전 | 1438 | |
| 818 |
|
19년 전 | 1598 | |
| 817 |
|
19년 전 | 1523 | |
| 816 |
|
19년 전 | 1447 | |
| 815 |
|
19년 전 | 1460 | |
| 814 |
|
19년 전 | 1381 | |
| 813 |
|
19년 전 | 1444 | |
| 812 | 19년 전 | 2819 | ||
| 811 |
pearly
|
19년 전 | 3836 | |
| 810 |
pearly
|
19년 전 | 5213 | |
| 809 |
|
19년 전 | 1377 | |
| 808 |
pearly
|
19년 전 | 4540 | |
| 807 | 19년 전 | 2980 | ||
| 806 |
|
19년 전 | 1504 | |
| 805 |
|
19년 전 | 2692 | |
| 804 |
|
19년 전 | 3617 | |
| 803 |
|
19년 전 | 1806 | |
| 802 |
|
19년 전 | 3790 | |
| 801 |
|
19년 전 | 1882 | |
| 800 | 19년 전 | 3771 | ||
| 799 | 19년 전 | 3434 | ||
| 798 | 19년 전 | 4206 | ||
| 797 | 19년 전 | 4062 | ||
| 796 |
|
19년 전 | 1897 | |
| 795 |
|
19년 전 | 1854 | |
| 794 | 19년 전 | 4274 | ||
| 793 | 19년 전 | 2669 | ||
| 792 | 19년 전 | 2548 | ||
| 791 | 19년 전 | 2395 | ||
| 790 | 19년 전 | 1976 | ||
| 789 | 19년 전 | 2593 | ||
| 788 | 19년 전 | 2205 | ||
| 787 | 19년 전 | 1845 | ||
| 786 | 19년 전 | 1972 | ||
| 785 | 19년 전 | 1443 | ||
| 784 |
|
19년 전 | 1695 | |
| 783 | 19년 전 | 2838 | ||
| 782 |
|
19년 전 | 1957 | |
| 781 | 19년 전 | 3247 | ||
| 780 | 19년 전 | 3157 | ||
| 779 |
|
19년 전 | 2243 | |
| 778 |
|
19년 전 | 1796 | |
| 777 | 19년 전 | 2839 | ||
| 776 | 19년 전 | 2902 | ||
| 775 | 19년 전 | 4018 | ||
| 774 |
|
19년 전 | 1977 | |
| 773 | 19년 전 | 2622 | ||
| 772 | 19년 전 | 2337 | ||
| 771 | 19년 전 | 3472 | ||
| 770 |
|
19년 전 | 1437 | |
| 769 | 19년 전 | 1496 | ||
| 768 | 19년 전 | 1768 | ||
| 767 | 19년 전 | 2202 | ||
| 766 | 19년 전 | 1833 | ||
| 765 | 19년 전 | 1693 | ||
| 764 |
|
19년 전 | 2111 | |
| 763 |
|
19년 전 | 2216 | |
| 762 |
|
19년 전 | 4963 | |
| 761 | 19년 전 | 2327 | ||
| 760 |
|
19년 전 | 3194 | |
| 759 | 19년 전 | 2641 | ||
| 758 |
|
19년 전 | 2405 | |
| 757 | 19년 전 | 4698 | ||
| 756 | 19년 전 | 2566 | ||
| 755 |
|
19년 전 | 2415 | |
| 754 |
|
19년 전 | 1955 | |
| 753 |
|
19년 전 | 1737 | |
| 752 |
pearly
|
19년 전 | 3369 | |
| 751 | 19년 전 | 2346 | ||
| 750 |
|
19년 전 | 6161 | |
| 749 | 19년 전 | 2029 | ||
| 748 |
|
19년 전 | 1904 | |
| 747 |
|
19년 전 | 2704 | |
| 746 |
|
19년 전 | 1815 | |
| 745 | 19년 전 | 2281 | ||
| 744 | 19년 전 | 2111 | ||
| 743 |
|
19년 전 | 3567 | |
| 742 | 19년 전 | 2580 | ||
| 741 | 19년 전 | 2746 | ||
| 740 |
|
19년 전 | 4369 | |
| 739 | 19년 전 | 3548 | ||
| 738 |
|
19년 전 | 2307 | |
| 737 | 19년 전 | 4313 | ||
| 736 | 19년 전 | 3268 | ||
| 735 |
홀로남은자
|
19년 전 | 4139 | |
| 734 |
홀로남은자
|
19년 전 | 2027 | |
| 733 |
홀로남은자
|
19년 전 | 2229 | |
| 732 | 19년 전 | 2139 | ||
| 731 | 19년 전 | 3354 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기