출처: 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>
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7730 | 10년 전 | 1301 | ||
| 7729 | 10년 전 | 1122 | ||
| 7728 |
잘살아보자
|
10년 전 | 585 | |
| 7727 |
잘살아보자
|
10년 전 | 476 | |
| 7726 |
잘살아보자
|
10년 전 | 804 | |
| 7725 |
잘살아보자
|
10년 전 | 535 | |
| 7724 |
잘살아보자
|
10년 전 | 448 | |
| 7723 |
잘살아보자
|
10년 전 | 516 | |
| 7722 |
잘살아보자
|
10년 전 | 452 | |
| 7721 |
잘살아보자
|
10년 전 | 491 | |
| 7720 |
잘살아보자
|
10년 전 | 441 | |
| 7719 |
비긴어게인
|
10년 전 | 682 | |
| 7718 |
|
10년 전 | 2518 | |
| 7717 |
잘살아보자
|
10년 전 | 640 | |
| 7716 |
잘살아보자
|
10년 전 | 388 | |
| 7715 |
잘살아보자
|
10년 전 | 422 | |
| 7714 |
잘살아보자
|
10년 전 | 469 | |
| 7713 | 10년 전 | 1773 | ||
| 7712 | 10년 전 | 1700 | ||
| 7711 | 10년 전 | 1081 | ||
| 7710 | 10년 전 | 1377 | ||
| 7709 | 10년 전 | 1501 | ||
| 7708 | 10년 전 | 1450 | ||
| 7707 | 10년 전 | 847 | ||
| 7706 |
별지기천사
|
10년 전 | 562 | |
| 7705 | 10년 전 | 1061 | ||
| 7704 |
ICONdesignstudio
|
10년 전 | 602 | |
| 7703 | 10년 전 | 576 | ||
| 7702 |
|
10년 전 | 710 | |
| 7701 | 10년 전 | 1397 | ||
| 7700 | 10년 전 | 1094 | ||
| 7699 | 10년 전 | 574 | ||
| 7698 | 10년 전 | 1122 | ||
| 7697 | 10년 전 | 5139 | ||
| 7696 | 10년 전 | 635 | ||
| 7695 | 10년 전 | 1675 | ||
| 7694 | 10년 전 | 1044 | ||
| 7693 | 10년 전 | 1539 | ||
| 7692 | 10년 전 | 1276 | ||
| 7691 | 10년 전 | 803 | ||
| 7690 | 10년 전 | 1380 | ||
| 7689 | 10년 전 | 999 | ||
| 7688 | 10년 전 | 594 | ||
| 7687 |
파랑새1597
|
10년 전 | 571 | |
| 7686 | 10년 전 | 831 | ||
| 7685 | 10년 전 | 1331 | ||
| 7684 | 10년 전 | 786 | ||
| 7683 | 10년 전 | 1065 | ||
| 7682 | 10년 전 | 979 | ||
| 7681 | 10년 전 | 641 | ||
| 7680 | 10년 전 | 981 | ||
| 7679 | 10년 전 | 489 | ||
| 7678 | 10년 전 | 717 | ||
| 7677 | 10년 전 | 620 | ||
| 7676 |
|
10년 전 | 934 | |
| 7675 |
|
10년 전 | 1151 | |
| 7674 | 10년 전 | 1040 | ||
| 7673 | 10년 전 | 743 | ||
| 7672 | 10년 전 | 1081 | ||
| 7671 | 10년 전 | 873 | ||
| 7670 | 10년 전 | 638 | ||
| 7669 |
mashmellow
|
10년 전 | 1221 | |
| 7668 | 10년 전 | 705 | ||
| 7667 | 10년 전 | 986 | ||
| 7666 |
senseme
|
10년 전 | 639 | |
| 7665 | 10년 전 | 493 | ||
| 7664 | 10년 전 | 1886 | ||
| 7663 |
mixx애교
|
10년 전 | 975 | |
| 7662 | 10년 전 | 1026 | ||
| 7661 |
hkhkah
|
10년 전 | 781 | |
| 7660 | 10년 전 | 1051 | ||
| 7659 |
커네드커네드
|
10년 전 | 917 | |
| 7658 |
바람돌이팡
|
10년 전 | 659 | |
| 7657 | 10년 전 | 1155 | ||
| 7656 | 10년 전 | 1560 | ||
| 7655 | 10년 전 | 970 | ||
| 7654 |
개발짜증나
|
10년 전 | 847 | |
| 7653 |
네이비칼라
|
10년 전 | 874 | |
| 7652 |
밥먹고합시다
|
10년 전 | 801 | |
| 7651 |
플라이SINJI
|
10년 전 | 1500 | |
| 7650 |
개발짜증나
|
10년 전 | 1400 | |
| 7649 | 10년 전 | 447 | ||
| 7648 |
이미영ㅇㅇ
|
10년 전 | 862 | |
| 7647 | 10년 전 | 419 | ||
| 7646 | 10년 전 | 788 | ||
| 7645 | 10년 전 | 2298 | ||
| 7644 | 10년 전 | 805 | ||
| 7643 |
|
10년 전 | 2861 | |
| 7642 | 10년 전 | 1499 | ||
| 7641 | 10년 전 | 1120 | ||
| 7640 |
개발짜증나
|
10년 전 | 464 | |
| 7639 |
|
10년 전 | 808 | |
| 7638 |
개발짜증나
|
10년 전 | 1123 | |
| 7637 | 10년 전 | 1540 | ||
| 7636 | 10년 전 | 2906 | ||
| 7635 | 10년 전 | 1676 | ||
| 7634 | 10년 전 | 1862 | ||
| 7633 | 10년 전 | 2320 | ||
| 7632 | 10년 전 | 3920 | ||
| 7631 |
|
10년 전 | 1523 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기