출처: 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년 전 | 438 | ||
| 7929 | 9년 전 | 368 | ||
| 7928 | 9년 전 | 456 | ||
| 7927 | 9년 전 | 368 | ||
| 7926 | 9년 전 | 680 | ||
| 7925 | 9년 전 | 391 | ||
| 7924 | 9년 전 | 376 | ||
| 7923 | 9년 전 | 371 | ||
| 7922 | 9년 전 | 403 | ||
| 7921 | 9년 전 | 419 | ||
| 7920 | 9년 전 | 337 | ||
| 7919 | 9년 전 | 346 | ||
| 7918 | 9년 전 | 500 | ||
| 7917 | 9년 전 | 353 | ||
| 7916 | 9년 전 | 436 | ||
| 7915 | 9년 전 | 436 | ||
| 7914 | 9년 전 | 448 | ||
| 7913 | 9년 전 | 621 | ||
| 7912 | 9년 전 | 455 | ||
| 7911 | 9년 전 | 388 | ||
| 7910 | 9년 전 | 435 | ||
| 7909 | 9년 전 | 536 | ||
| 7908 | 9년 전 | 473 | ||
| 7907 | 9년 전 | 413 | ||
| 7906 | 9년 전 | 429 | ||
| 7905 | 9년 전 | 402 | ||
| 7904 | 9년 전 | 387 | ||
| 7903 | 9년 전 | 385 | ||
| 7902 | 9년 전 | 583 | ||
| 7901 |
|
9년 전 | 762 | |
| 7900 | 9년 전 | 631 | ||
| 7899 | 9년 전 | 415 | ||
| 7898 | 9년 전 | 423 | ||
| 7897 | 9년 전 | 375 | ||
| 7896 | 9년 전 | 388 | ||
| 7895 | 9년 전 | 502 | ||
| 7894 | 9년 전 | 422 | ||
| 7893 | 9년 전 | 390 | ||
| 7892 | 9년 전 | 426 | ||
| 7891 | 9년 전 | 792 | ||
| 7890 | 9년 전 | 1224 | ||
| 7889 | 9년 전 | 760 | ||
| 7888 |
limsy1987
|
9년 전 | 569 | |
| 7887 | 9년 전 | 595 | ||
| 7886 | 9년 전 | 490 | ||
| 7885 | 9년 전 | 445 | ||
| 7884 | 9년 전 | 440 | ||
| 7883 | 9년 전 | 447 | ||
| 7882 | 9년 전 | 503 | ||
| 7881 | 9년 전 | 472 | ||
| 7880 | 9년 전 | 603 | ||
| 7879 | 9년 전 | 495 | ||
| 7878 | 9년 전 | 1260 | ||
| 7877 | 9년 전 | 790 | ||
| 7876 | 9년 전 | 524 | ||
| 7875 | 9년 전 | 601 | ||
| 7874 |
|
9년 전 | 824 | |
| 7873 | 9년 전 | 540 | ||
| 7872 | 9년 전 | 704 | ||
| 7871 | 9년 전 | 519 | ||
| 7870 | 9년 전 | 642 | ||
| 7869 | 9년 전 | 454 | ||
| 7868 | 9년 전 | 485 | ||
| 7867 | 9년 전 | 481 | ||
| 7866 | 9년 전 | 538 | ||
| 7865 | 9년 전 | 480 | ||
| 7864 | 9년 전 | 547 | ||
| 7863 | 9년 전 | 545 | ||
| 7862 | 9년 전 | 495 | ||
| 7861 | 9년 전 | 674 | ||
| 7860 | 9년 전 | 653 | ||
| 7859 | 9년 전 | 436 | ||
| 7858 | 9년 전 | 736 | ||
| 7857 | 9년 전 | 1120 | ||
| 7856 | 9년 전 | 555 | ||
| 7855 | 9년 전 | 781 | ||
| 7854 | 9년 전 | 742 | ||
| 7853 | 9년 전 | 627 | ||
| 7852 | 9년 전 | 550 | ||
| 7851 | 9년 전 | 539 | ||
| 7850 | 9년 전 | 618 | ||
| 7849 | 9년 전 | 386 | ||
| 7848 | 9년 전 | 458 | ||
| 7847 | 9년 전 | 697 | ||
| 7846 | 9년 전 | 486 | ||
| 7845 | 9년 전 | 454 | ||
| 7844 | 9년 전 | 427 | ||
| 7843 | 9년 전 | 461 | ||
| 7842 | 9년 전 | 440 | ||
| 7841 | 9년 전 | 416 | ||
| 7840 | 9년 전 | 429 | ||
| 7839 | 9년 전 | 469 | ||
| 7838 | 9년 전 | 535 | ||
| 7837 | 9년 전 | 380 | ||
| 7836 | 9년 전 | 430 | ||
| 7835 | 9년 전 | 507 | ||
| 7834 |
|
9년 전 | 1213 | |
| 7833 | 10년 전 | 471 | ||
| 7832 | 10년 전 | 453 | ||
| 7831 | 10년 전 | 603 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기