我自己借用精華區(qū)里的MIME類寫了一個基本的發(fā)信小東東(2)
Jun 21, 2016 am 09:13 AMmime|精華
sendmail.php4
//加載發(fā)送附件的類
require('html_mime_mail.inc');
if($update!=""){??//如果帶附件
????
????//上傳附件
????if(!file_exists("c:/ftptmp/".$myfile_name)){
????????if(copy($myfile,"c:/ftptmp/".$myfile_name)){
????????????//讀取附件
????????????$attachment = fread($fp = fopen("c:/ftptmp/".$myfile_name, 'r'), filesize($myfile));
????????????fclose($fp);
????????????//unlink("c:/ftptmp/".$myfile_name);刪掉
????????}
????????else {
????????????echo "上傳文件失??!";
????????????exit();
????????}
????}
????else{
????????echo "文件重名!";
????????exit();
????}
????
????
????//新建一個類的實例,并加入附件
????$mail = new html_mime_mail();
????$mail->add_attachment($attachment, $myfile_name, 'application/octet-stream');
????
????/*---------------------這段示范了如何發(fā)HTML信件---------------------------------------
????$filename = 'background.gif';
????$backgrnd = fread($fp = fopen($filename, 'r'), filesize($filename));
????fclose($fp);
????$text = 'This is a test.';
????$html = '
';
????
????$mail->add_html_image($backgrnd, 'background.gif', 'image/gif');
????$mail->add_html($html, $text);
????-------------------------------------------------------------------------------------*/
????
????//讀取正文,將信件封裝并發(fā)送
????$mail->body=$bodytext;
????$mail->build_message();
????$backvalue=$mail->send(' ',$receivemailbox,' ',$sendmailbox,$subject,' ');
????
????//發(fā)送提示信息
????echo "<script>alert('發(fā)信OK,按確定返回!');window.location='default.htm'</script>";
}
else{??//如果不帶附件
????$backvalue=mail($receivemailbox,$subject,$bodytext,"From:" . $sendmailbox . "\nReply-To:" . $sendmailbox . "\nX-Mailer: PHP/" . phpversion());
????
????if ($result) {
????????echo "";
????}
????else{
????????echo "";
????}
}
?>
html_mime_mail.inc 這個類是精華區(qū)里有的。我借來一用
class html_mime_mail{
var $headers;
var $body;
var $multipart;
var $mime;
var $html;
var $html_text;
var $html_images = array();
var $cids = array();
var $do_html;
var $parts = array();
/***************************************
** Constructor function. Sets the headers
** if supplied.
***************************************/
function html_mime_mail($headers = ''){
$this->headers = $headers;
}
/***************************************
** Adds a html part to the mail.
** Also replaces image names with
** content-id's.
***************************************/
function add_html($html, $text){
$this->do_html = 1;
$this->html = $html;
$this->html_text = $text;
if(is_array($this->html_images) AND count($this->html_images) > 0){
for($i=0; $i
$this->html = ereg_replace($this->html_images[$i]['name'], 'cid:'.$this->html_images[$i]['cid'], $this->html);
}
}
}
/***************************************
** Builds html part of email.
***************************************/
function build_html($orig_boundary){
$sec_boundary = '=_'.md5(uniqid(time()));
$thr_boundary = '=_'.md5(uniqid(time()));
if(!is_array($this->html_images)){
$this->multipart.= '--'.$orig_boundary."\r\n";
$this->multipart.= 'Content-Type: multipart/alternative; boundary="'.$sec_boundary."\"\r\n\r\n\r\n";
$this->multipart.= '--'.$sec_boundary."\r\n";
$this->multipart.= 'Content-Type: text/plain'."\r\n";
$this->multipart.= 'Content-Transfer-Encoding: 7bit'."\r\n\r\n";
$this->multipart.= $this->html_text."\r\n\r\n";
$this->multipart.= '--'.$sec_boundary."\r\n";
$this->multipart.= 'Content-Type: text/html'."\r\n";
$this->multipart.= 'Content-Transfer-Encoding: 7bit'."\r\n\r\n";
$this->multipart.= $this->html."\r\n\r\n";
$this->multipart.= '--'.$sec_boundary."--\r\n\r\n";
}else{
$this->multipart.= '--'.$orig_boundary."\r\n";
$this->multipart.= 'Content-Type: multipart/related; boundary="'.$sec_boundary."\"\r\n\r\n\r\n";
$this->multipart.= '--'.$sec_boundary."\r\n";
$this->multipart.= 'Content-Type: multipart/alternative; boundary="'.$thr_boundary."\"\r\n\r\n\r\n";
$this->multipart.= '--'.$thr_boundary."\r\n";
$this->multipart.= 'Content-Type: text/plain'."\r\n";
$this->multipart.= 'Content-Transfer-Encoding: 7bit'."\r\n\r\n";
$this->multipart.= $this->html_text."\r\n\r\n";
$this->multipart.= '--'.$thr_boundary."\r\n";
$this->multipart.= 'Content-Type: text/html'."\r\n";
$this->multipart.= 'Content-Transfer-Encoding: 7bit'."\r\n\r\n";
$this->multipart.= $this->html."\r\n\r\n";
$this->multipart.= '--'.$thr_boundary."--\r\n\r\n";
for($i=0; $i
$this->multipart.= '--'.$sec_boundary."\r\n";
$this->build_html_image($i);
}
$this->multipart.= "--".$sec_boundary."--\r\n\r\n";
}
}
/***************************************
** Adds an image to the list of embedded
** images.
***************************************/
function add_html_image($file, $name = '', $c_type='application/octet-stream'){
$this->html_images[] = array( 'body' => $file,
'name' => $name,
'c_type' => $c_type,
'cid' => md5(uniqid(time())) );
}
/***************************************
** Adds a file to the list of attachments.
***************************************/
function add_attachment($file, $name = '', $c_type='application/octet-stream'){
$this->parts[] = array( 'body' => $file,
'name' => $name,
'c_type' => $c_type );
}
/***************************************
** Builds an embedded image part of an
** html mail.
***************************************/
function build_html_image($i){
$this->multipart.= 'Content-Type: '.$this->html_images[$i]['c_type'];
if($this->html_images[$i]['name'] != '') $this->multipart .= '; name="'.$this->html_images[$i]['name']."\"\r\n";
else $this->multipart .= "\r\n";
$this->multipart.= 'Content-ID: html_images[$i]['cid'].">\r\n";
$this->multipart.= 'Content-Transfer-Encoding: base64'."\r\n\r\n";
$this->multipart.= chunk_split(base64_encode($this->html_images[$i]['body']))."\r\n";
}
/***************************************
** Builds a single part of a multipart
** message.
***************************************/
function build_part($i){
$message_part = '';
$message_part.= 'Content-Type: '.$this->parts[$i]['c_type'];
if($this->parts[$i]['name'] != '')
$message_part .= '; name="'.$this->parts[$i]['name']."\"\r\n";
else
$message_part .= "\r\n";
// Determine content encoding.
if($this->parts[$i]['c_type'] == 'text/plain'){
$message_part.= 'Content-Transfer-Encoding: 7bit'."\r\n\r\n";
$message_part.= $this->parts[$i]['body']."\r\n";
}else{
$message_part.= 'Content-Transfer-Encoding: base64'."\r\n";
$message_part.= 'Content-Disposition: attachment; filename="'.$this->parts[$i]['name']."\"\r\n\r\n";
$message_part.= chunk_split(base64_encode($this->parts[$i]['body']))."\r\n";
}
return $message_part;
}
/***************************************
** Builds the multipart message from the
** list ($this->parts).
***************************************/
function build_message(){
$boundary = '=_'.md5(uniqid(time()));
$this->headers.= "MIME-Version: 1.0\r\n";
$this->headers.= "Content-Type: multipart/mixed; boundary=\"".$boundary."\"\r\n";
$this->multipart = '';
$this->multipart.= "This is a MIME encoded message.\r\nCreated by html_mime_mail.class.\r\nSee http://www.heyes-computing.net/scripts/ for a copy.\r\n\r\n";
if(isset($this->do_html) AND $this->do_html == 1) $this->build_html($boundary);
if(isset($this->body) AND $this->body != '') $this->parts[] = array('body' => $this->body, 'name' => '', 'c_type' => 'text/plain');
for($i=(count($this->parts)-1); $i>=0; $i--){
$this->multipart.= '--'.$boundary."\r\n".$this->build_part($i);
}
$this->mime = $this->multipart."--".$boundary."--\r\n";
}
/***************************************
** Sends the mail.
***************************************/
function send($to_name, $to_addr, $from_name, $from_addr, $subject = '', $headers = ''){
if($to_name != '') $to = '"'.$to_name.'" ';
else $to = $to_addr;
if($from_name != '') $from = '"'.$from_name.'" ';
else $from = $from_addr;
$this->headers.= 'From: '.$from."\r\n";
//$this->headers.= $headers;
mail($to, $subject, $this->mime, $this->headers);
}
/***************************************
** Use this method to deliver using direct
** smtp connection. Relies upon Manuel Lemos'
** smtp mail delivery class available at:
** http://phpclasses.upperdesign.com
**
** void smtp_send( string *Name* of smtp object,
** string From address,
** array To addresses,
** array Headers,
** string The body)
***************************************/
function smtp_send($smtp_obj, $from_addr, $to_addr){
global $$smtp_obj;
$smtp_obj = $$smtp_obj;
if(substr($this->headers, -2) == "\r\n") $this->headers = substr($this->headers,0,-2);
$this->headers = explode("\r\n", $this->headers);
$smtp_obj->sendmessage($from_addr, $to_addr, $this->headers, $this->mime);
}
} // End of class.
?>

熱AI工具

Undress AI Tool
免費(fèi)脫衣圖片

Undresser.AI Undress
人工智慧驅(qū)動的應(yīng)用程序,用於創(chuàng)建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費(fèi)的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費(fèi)的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強(qiáng)大的PHP整合開發(fā)環(huán)境

Dreamweaver CS6
視覺化網(wǎng)頁開發(fā)工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

Windows11將清新優(yōu)雅的設(shè)計帶到了最前沿;現(xiàn)代介面可讓您個性化和更改最精細(xì)的細(xì)節(jié),例如視窗邊框。在本指南中,我們將討論逐步說明,以協(xié)助您在Windows作業(yè)系統(tǒng)中建立反映您的風(fēng)格的環(huán)境。如何更改視窗邊框設(shè)定?按+開啟“設(shè)定”應(yīng)用程式。 WindowsI前往個人化,然後按一下顏色設(shè)定。顏色變更視窗邊框設(shè)定視窗11「寬度=」643「高度=」500「>找到在標(biāo)題列和視窗邊框上顯示強(qiáng)調(diào)色選項,然後切換它旁邊的開關(guān)。若要在「開始」功能表和工作列上顯示主題色,請開啟「在開始」功能表和工作列上顯示主題

「你的組織要求你更改PIN訊息」將顯示在登入畫面上。當(dāng)在使用基於組織的帳戶設(shè)定的電腦上達(dá)到PIN過期限制時,就會發(fā)生這種情況,在該電腦上,他們可以控制個人設(shè)備。但是,如果您使用個人帳戶設(shè)定了Windows,則理想情況下不應(yīng)顯示錯誤訊息。雖然情況並非總是如此。大多數(shù)遇到錯誤的使用者使用個人帳戶報告。為什麼我的組織要求我在Windows11上更改我的PIN?可能是您的帳戶與組織相關(guān)聯(lián),您的主要方法應(yīng)該是驗證這一點。聯(lián)絡(luò)網(wǎng)域管理員會有所幫助!此外,配置錯誤的本機(jī)原則設(shè)定或不正確的登錄項目也可能導(dǎo)致錯誤。即

預(yù)設(shè)情況下,Windows11上的標(biāo)題列顏色取決於您選擇的深色/淺色主題。但是,您可以將其變更為所需的任何顏色。在本指南中,我們將討論三種方法的逐步說明,以更改它並個性化您的桌面體驗,使其具有視覺吸引力。是否可以更改活動和非活動視窗的標(biāo)題列顏色?是的,您可以使用「設(shè)定」套用變更活動視窗的標(biāo)題列顏色,也可以使用登錄編輯程式變更非活動視窗的標(biāo)題列顏色。若要了解這些步驟,請前往下一部分。如何在Windows11中變更標(biāo)題列的顏色? 1.使用「設(shè)定」應(yīng)用程式按+開啟設(shè)定視窗。 WindowsI前往“個人化”,然

工作列縮圖可能很有趣,但它們也可能分散注意力或煩人??紤]到您將滑鼠懸停在該區(qū)域的頻率,您可能無意中關(guān)閉了重要視窗幾次。另一個缺點是它使用更多的系統(tǒng)資源,因此,如果您一直在尋找一種提高資源效率的方法,我們將向您展示如何停用它。不過,如果您的硬體規(guī)格可以處理它並且您喜歡預(yù)覽版,則可以啟用它。如何在Windows11中啟用工作列縮圖預(yù)覽? 1.使用「設(shè)定」應(yīng)用程式點擊鍵並點選設(shè)定。 Windows按一下系統(tǒng),然後選擇關(guān)於。點選高級系統(tǒng)設(shè)定。導(dǎo)航至“進(jìn)階”選項卡,然後選擇“效能”下的“設(shè)定”。在「視覺效果」選

您是否在Windows安裝程式頁面上看到「出現(xiàn)問題」以及「OOBELANGUAGE」語句? Windows的安裝有時會因此類錯誤而停止。 OOBE表示開箱即用的體驗。正如錯誤提示所表示的那樣,這是與OOBE語言選擇相關(guān)的問題。沒有什麼好擔(dān)心的,你可以透過OOBE螢?zāi)槐旧淼钠猎]冊表編輯來解決這個問題??焖傩迯?fù)–1.點選OOBE應(yīng)用底部的「重試」按鈕。這將繼續(xù)進(jìn)行該過程,而不會再打嗝。 2.使用電源按鈕強(qiáng)制關(guān)閉系統(tǒng)。系統(tǒng)重新啟動後,OOBE應(yīng)繼續(xù)。 3.斷開系統(tǒng)與網(wǎng)際網(wǎng)路的連接。在脫機(jī)模式下完成OOBE的所

螢?zāi)涣炼仁鞘褂矛F(xiàn)代計算設(shè)備不可或缺的一部分,尤其是當(dāng)您長時間注視螢?zāi)粫r。它可以幫助您減輕眼睛疲勞,提高易讀性,並輕鬆有效地查看內(nèi)容。但是,根據(jù)您的設(shè)置,有時很難管理亮度,尤其是在具有新UI更改的Windows11上。如果您在調(diào)整亮度時遇到問題,以下是在Windows11上管理亮度的所有方法。如何在Windows11上變更亮度[10種方式解釋]單一顯示器使用者可以使用下列方法在Windows11上調(diào)整亮度。這包括使用單一顯示器的桌上型電腦系統(tǒng)以及筆記型電腦。讓我們開始吧。方法1:使用操作中心操作中心是訪問

在Windows11上的顯示縮放方面,我們都有不同的偏好。有些人喜歡大圖標(biāo),有些人喜歡小圖標(biāo)。但是,我們都同意擁有正確的縮放比例很重要。字體縮放不良或圖像過度縮放可能是工作時真正的生產(chǎn)力殺手,因此您需要知道如何自訂以充分利用系統(tǒng)功能。自訂縮放的優(yōu)點:對於難以閱讀螢?zāi)簧系奈淖值娜藖碚f,這是一個有用的功能。它可以幫助您一次在螢?zāi)簧喜榭锤鄡?nèi)容。您可以建立僅適用於某些監(jiān)視器和應(yīng)用程式的自訂擴(kuò)充功能設(shè)定檔??梢詭椭岣叩碗A硬體的效能。它使您可以更好地控制螢?zāi)簧系膬?nèi)容。如何在Windows11

Windows上的啟動過程有時會突然轉(zhuǎn)向顯示包含此錯誤代碼0xc004f069的錯誤訊息。雖然啟動程序已經(jīng)聯(lián)機(jī),但一些運(yùn)行WindowsServer的舊系統(tǒng)可能會遇到此問題。透過這些初步檢查,如果這些檢查不能幫助您啟動系統(tǒng),請?zhí)街饕鉀Q方案以解決問題。解決方法–關(guān)閉錯誤訊息和啟動視窗。然後,重新啟動電腦。再次從頭開始重試Windows啟動程序。修復(fù)1–從終端啟動從cmd終端啟動WindowsServerEdition系統(tǒng)。階段–1檢查Windows伺服器版本您必須檢查您使用的是哪種類型的W
