출처: 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>
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7930 | 9년 전 | 452 | ||
| 7929 | 9년 전 | 385 | ||
| 7928 | 9년 전 | 463 | ||
| 7927 | 9년 전 | 378 | ||
| 7926 | 9년 전 | 688 | ||
| 7925 | 9년 전 | 401 | ||
| 7924 | 9년 전 | 383 | ||
| 7923 | 9년 전 | 379 | ||
| 7922 | 9년 전 | 413 | ||
| 7921 | 9년 전 | 430 | ||
| 7920 | 9년 전 | 343 | ||
| 7919 | 9년 전 | 352 | ||
| 7918 | 9년 전 | 507 | ||
| 7917 | 9년 전 | 357 | ||
| 7916 | 9년 전 | 446 | ||
| 7915 | 9년 전 | 453 | ||
| 7914 | 9년 전 | 466 | ||
| 7913 | 9년 전 | 633 | ||
| 7912 | 9년 전 | 464 | ||
| 7911 | 9년 전 | 397 | ||
| 7910 | 9년 전 | 444 | ||
| 7909 | 9년 전 | 550 | ||
| 7908 | 9년 전 | 488 | ||
| 7907 | 9년 전 | 426 | ||
| 7906 | 9년 전 | 443 | ||
| 7905 | 9년 전 | 409 | ||
| 7904 | 9년 전 | 399 | ||
| 7903 | 9년 전 | 398 | ||
| 7902 | 9년 전 | 589 | ||
| 7901 |
|
9년 전 | 766 | |
| 7900 | 9년 전 | 647 | ||
| 7899 | 9년 전 | 430 | ||
| 7898 | 9년 전 | 428 | ||
| 7897 | 9년 전 | 386 | ||
| 7896 | 9년 전 | 397 | ||
| 7895 | 9년 전 | 515 | ||
| 7894 | 9년 전 | 431 | ||
| 7893 | 9년 전 | 404 | ||
| 7892 | 9년 전 | 443 | ||
| 7891 | 9년 전 | 802 | ||
| 7890 | 9년 전 | 1231 | ||
| 7889 | 9년 전 | 766 | ||
| 7888 |
limsy1987
|
9년 전 | 577 | |
| 7887 | 9년 전 | 607 | ||
| 7886 | 9년 전 | 495 | ||
| 7885 | 9년 전 | 463 | ||
| 7884 | 9년 전 | 456 | ||
| 7883 | 9년 전 | 461 | ||
| 7882 | 9년 전 | 520 | ||
| 7881 | 9년 전 | 493 | ||
| 7880 | 9년 전 | 617 | ||
| 7879 | 9년 전 | 501 | ||
| 7878 | 9년 전 | 1276 | ||
| 7877 | 9년 전 | 806 | ||
| 7876 | 9년 전 | 541 | ||
| 7875 | 9년 전 | 614 | ||
| 7874 |
|
9년 전 | 829 | |
| 7873 | 9년 전 | 549 | ||
| 7872 | 9년 전 | 713 | ||
| 7871 | 9년 전 | 530 | ||
| 7870 | 9년 전 | 648 | ||
| 7869 | 9년 전 | 464 | ||
| 7868 | 9년 전 | 504 | ||
| 7867 | 9년 전 | 500 | ||
| 7866 | 9년 전 | 557 | ||
| 7865 | 9년 전 | 494 | ||
| 7864 | 9년 전 | 558 | ||
| 7863 | 9년 전 | 553 | ||
| 7862 | 9년 전 | 517 | ||
| 7861 | 9년 전 | 688 | ||
| 7860 | 9년 전 | 665 | ||
| 7859 | 9년 전 | 443 | ||
| 7858 | 9년 전 | 745 | ||
| 7857 | 9년 전 | 1135 | ||
| 7856 | 9년 전 | 566 | ||
| 7855 | 9년 전 | 799 | ||
| 7854 | 9년 전 | 753 | ||
| 7853 | 9년 전 | 642 | ||
| 7852 | 9년 전 | 564 | ||
| 7851 | 9년 전 | 554 | ||
| 7850 | 9년 전 | 633 | ||
| 7849 | 9년 전 | 400 | ||
| 7848 | 9년 전 | 465 | ||
| 7847 | 9년 전 | 709 | ||
| 7846 | 9년 전 | 494 | ||
| 7845 | 9년 전 | 466 | ||
| 7844 | 9년 전 | 438 | ||
| 7843 | 9년 전 | 474 | ||
| 7842 | 9년 전 | 454 | ||
| 7841 | 9년 전 | 428 | ||
| 7840 | 9년 전 | 442 | ||
| 7839 | 9년 전 | 484 | ||
| 7838 | 10년 전 | 550 | ||
| 7837 | 10년 전 | 382 | ||
| 7836 | 10년 전 | 441 | ||
| 7835 | 10년 전 | 516 | ||
| 7834 |
|
10년 전 | 1227 | |
| 7833 | 10년 전 | 487 | ||
| 7832 | 10년 전 | 461 | ||
| 7831 | 10년 전 | 623 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기