PHP郵件專題

來源:互聯網
上載者:User

PHP SMTP類

<?
/***********************************
PHP MIME SMTP ver 1.0 Powered by Boss_ch, Unigenius soft ware co. Ltd
All rights reserved, Copyright 2000 ;
本類用 PHP 通過 smtp  sock 操作發送 MIME 類型的郵件,可以發送
HTML 格式的本文、附件,採用 base64 編碼
本版本是針對個人的發送,與多人群發版本不同的是,每發送到一個人,就重新進行一次編碼,在接收端的使用者看來,只是發送給他一個人的。
針對多人群發的情況,只發送一次,通過多個 RCPT TO 命令發送到不同的人信箱中,
說明:
請把 $hostname 設為你有許可權的 預設 smtp 伺服器或是在 new 時指定
把 $charset 改成你的預設 字元集
Html 本文中如有圖片,請用絕對路徑的引用 "yun_qi_img/image.gif";
  並連上網,以保證程式能讀取到圖片的資料資訊
假如是通過表單提交過來的 Html 本文,請先用 StripSlashes($html_body) 把本文內容進行預先處理
  Html 中用到的樣式表檔案,請不要用 <link >之類 的引用,直接把樣式表定義放在
<style></style>標籤中

*************************************/
if(!isset($__smtp_class__)){
$__smtp_class__=1;

class smtp
{
var $hostname="";
var $port=25;
var $connection=0;
var $debug=1;

var $timeout=30;
var $err_str;
var $err_no;

var $autocode=true;
var $charset="??????";
var $subject="";
var $body="";
var $attach="";
var $temp_text_body;
var $temp_html_body;
var $temp_body_images;

var $bound_begin="=====powered_by_boss_chen_";
var $bound_end="_046484063883_=====";

Function smtp($server="smtp.china.com",$port=25,$time_out=20)
{$this->hostname=$server;
$this->port=$port;
$this->timeout=$time_out;
return true;
}

Function outdebug($message)
{
echo htmlspecialchars($message)."<br>n";
}


function command($command,$return_lenth=1,$return_code='2')
{
if ($this->connection==0)
{
$this->err_str="沒有串連到任何伺服器,請檢查網路連接";
return false;
}
if ($this->debug)
$this->outdebug(">>> $command");
if (!fputs($this->connection,"$command rn"))
{
$this->err_str="無法發送命令".$command;
return false;
}
else
{
$resp=fgets($this->connection,256);
if($this->debug)
$this->outdebug("$resp");

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.