持stmp認證 HTML格式郵件

2021-04-01 07:46:09 字數 2338 閱讀 6141

c_**tp_client.php

<?php

/* **tp client class */

class c_**tp_client

else

$this->connection = fsockopen($this->server, 25);

if ($this->connection <= 0) return 0;

fputs($this->connection,"helo xyz/r/n");

} function email($from_mail, $to_mail, $to_name, $header, $subject, $body)

$this->elog("mail from:$from_mail", 1);

fputs($this->connection,"mail from:$from_mail/r/n");

$this->elog(fgets($this->connection, 1024));

$this->elog("rcpt to:$to_mail", 1);

fputs($this->connection, "rcpt to:$to_mail/r/n");

$this->elog(fgets($this->connection, 1024));

$this->elog("data", 1);

fputs($this->connection, "data/r/n");

$this->elog(fgets($this->connection, 1024));

$this->elog("subject: $subject", 1);

$this->elog("to: $to_name", 1);

fputs($this->connection,"subject: $subject/r/n");

fputs($this->connection,"to: $to_name/r/n");

if ($header)

$this->elog("", 1);

$this->elog($body, 1);

$this->elog(".", 1);

fputs($this->connection,"/r/n");

fputs($this->connection,"$body /r/n");

fputs($this->connection,"./r/n");

$this->elog(fgets($this->connection, 1024));

return 1;

} function send() }

function close()

function elog($text, $mode=0)

// write to log

if (!$mode)

else}}

?>

c_mail.php

<?php

/* 郵件傳送類 */

require_once dirname(__file__)."/c_**tp_client.php";

static $c_**tp_client;

if(!isset($c_**tp_client))

class c_mail

else}}

?>

config.inc.php

<?php

//**tp_server['name']=='';則表示直接使用mail();          

//**tp_server['name']=='localhost';表示程式所在主機的**tp伺服器

$**tp_server['name']            =    "";

$**tp_server['need_auth']       =    true;

$**tp_server['username']        =    '';

$**tp_server['password']        =    '';

?>

sendmail.php

<?php

//呼叫方法

require_once dirname(__file__)."/config.inc.php";

require_once dirname(__file__)."/c_mail.php";

$c_mail    = new c_mail();

$c_mail->html_mailer($from_name,$from_mail,$to_name,$to_mail,$subject,$message,$reply_mail);

?>