출처: 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>
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8030 | 9년 전 | 378 | ||
| 8029 | 9년 전 | 313 | ||
| 8028 | 9년 전 | 268 | ||
| 8027 | 9년 전 | 285 | ||
| 8026 | 9년 전 | 342 | ||
| 8025 | 9년 전 | 391 | ||
| 8024 | 9년 전 | 348 | ||
| 8023 | 9년 전 | 396 | ||
| 8022 | 9년 전 | 323 | ||
| 8021 | 9년 전 | 331 | ||
| 8020 | 9년 전 | 323 | ||
| 8019 | 9년 전 | 345 | ||
| 8018 | 9년 전 | 449 | ||
| 8017 | 9년 전 | 539 | ||
| 8016 | 9년 전 | 336 | ||
| 8015 | 9년 전 | 392 | ||
| 8014 | 9년 전 | 329 | ||
| 8013 | 9년 전 | 242 | ||
| 8012 | 9년 전 | 245 | ||
| 8011 | 9년 전 | 449 | ||
| 8010 | 9년 전 | 306 | ||
| 8009 | 9년 전 | 296 | ||
| 8008 | 9년 전 | 291 | ||
| 8007 | 9년 전 | 433 | ||
| 8006 | 9년 전 | 466 | ||
| 8005 |
|
9년 전 | 971 | |
| 8004 | 9년 전 | 362 | ||
| 8003 | 9년 전 | 428 | ||
| 8002 | 9년 전 | 324 | ||
| 8001 |
|
9년 전 | 667 | |
| 8000 | 9년 전 | 423 | ||
| 7999 | 9년 전 | 377 | ||
| 7998 | 9년 전 | 434 | ||
| 7997 | 9년 전 | 315 | ||
| 7996 | 9년 전 | 535 | ||
| 7995 | 9년 전 | 459 | ||
| 7994 | 9년 전 | 339 | ||
| 7993 | 9년 전 | 401 | ||
| 7992 | 9년 전 | 516 | ||
| 7991 | 9년 전 | 254 | ||
| 7990 | 9년 전 | 296 | ||
| 7989 | 9년 전 | 309 | ||
| 7988 | 9년 전 | 735 | ||
| 7987 | 9년 전 | 431 | ||
| 7986 | 9년 전 | 425 | ||
| 7985 | 9년 전 | 512 | ||
| 7984 | 9년 전 | 434 | ||
| 7983 | 9년 전 | 663 | ||
| 7982 | 9년 전 | 524 | ||
| 7981 | 9년 전 | 476 | ||
| 7980 | 9년 전 | 500 | ||
| 7979 | 9년 전 | 479 | ||
| 7978 | 9년 전 | 458 | ||
| 7977 | 9년 전 | 395 | ||
| 7976 | 9년 전 | 853 | ||
| 7975 | 9년 전 | 364 | ||
| 7974 | 9년 전 | 400 | ||
| 7973 | 9년 전 | 601 | ||
| 7972 | 9년 전 | 386 | ||
| 7971 | 9년 전 | 460 | ||
| 7970 | 9년 전 | 305 | ||
| 7969 | 9년 전 | 549 | ||
| 7968 | 9년 전 | 389 | ||
| 7967 | 9년 전 | 379 | ||
| 7966 | 9년 전 | 375 | ||
| 7965 |
|
9년 전 | 1018 | |
| 7964 | 9년 전 | 400 | ||
| 7963 | 9년 전 | 404 | ||
| 7962 | 9년 전 | 382 | ||
| 7961 |
전갈자리남자
|
9년 전 | 510 | |
| 7960 | 9년 전 | 969 | ||
| 7959 | 9년 전 | 556 | ||
| 7958 | 9년 전 | 409 | ||
| 7957 | 9년 전 | 369 | ||
| 7956 | 9년 전 | 371 | ||
| 7955 | 9년 전 | 462 | ||
| 7954 | 9년 전 | 384 | ||
| 7953 | 9년 전 | 438 | ||
| 7952 | 9년 전 | 360 | ||
| 7951 | 9년 전 | 506 | ||
| 7950 | 9년 전 | 396 | ||
| 7949 | 9년 전 | 390 | ||
| 7948 | 9년 전 | 324 | ||
| 7947 | 9년 전 | 940 | ||
| 7946 | 9년 전 | 442 | ||
| 7945 | 9년 전 | 399 | ||
| 7944 | 9년 전 | 429 | ||
| 7943 | 9년 전 | 387 | ||
| 7942 | 9년 전 | 408 | ||
| 7941 | 9년 전 | 399 | ||
| 7940 | 9년 전 | 887 | ||
| 7939 | 9년 전 | 359 | ||
| 7938 | 9년 전 | 392 | ||
| 7937 | 9년 전 | 285 | ||
| 7936 | 9년 전 | 887 | ||
| 7935 | 9년 전 | 456 | ||
| 7934 | 9년 전 | 421 | ||
| 7933 | 9년 전 | 522 | ||
| 7932 | 9년 전 | 494 | ||
| 7931 | 9년 전 | 545 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기