程序
error_reporting(63);
include('class.html_mime_mail.inc');
/***************************************
** Example of usage.
***************************************/
/***************************************
** Read the file background.gif into
** $backgrnd.
***************************************/
$filename = 'background.gif';
$backgrnd = fread($fp = fopen($filename, 'r'), filesize($filename));
fclose($fp);
/***************************************
** Read the file test.zip into $attachment.
***************************************/
$filename = 'example.zip';
$attachment = fread($fp = fopen($filename, 'r'), filesize($filename));
fclose($fp);
/***************************************
** Create the mail object. Optional headers
** argument. Do not put From: here, this
** will be added when $mail->send
***************************************/
$mail = new html_mime_mail("X-Mailer: Html Mime Mail Class\r\n");
/***************************************
** If sending an html email, then these
** two variables specify the text and
** html versions of the mail. Don't
** have to be named as these are. Just
** make sure the names tie in to the
** $mail->add_html() command further down.
***************************************/
$text = 'This is a test.';
$html = '
';
/***************************************
** Add the text, html and embedded images.
** Each embedded image has to be added
** using $mail->add_html_image() BEFORE
** calling $mail->add_html(). The name
** of the image should match exactly
** (case-sensitive) to the name in the html.
***************************************/
$mail->add_html_image($backgrnd, 'background.gif', 'image/gif');
$mail->add_html($html, $text);
/***************************************
** If not sending an html email, then
** this is used to set the plain text
** body of the email.
***************************************/
// $mail->body = 'fsss';
/***************************************
** This is used to add an attachment to
** the email.
***************************************/
$mail->add_attachment($attachment, 'example.zip', 'application/octet-stream');
/***************************************
** Builds the message.
***************************************/
$mail->build_message();
/***************************************
** Sends the message. $mail->build_message()
** is seperate to $mail->send so that the
** same email can be sent many times to
** differing recipients simply by putting
** $mail->send() in a loop.
***************************************/
$mail->send('','szw@phpexe.com', 'From Name', 'szw@phpexe.com', 'Subject','');
/***************************************
** Debug stuff. Entirely unnecessary.
***************************************/
echo '
'; <br>echo $mail->mime; <br>echo '';
?>
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();
/****************************************
** コンストラクター関数。ヘッダー
** が指定されている場合はそれを設定します。
**************************************/
function html_mime_mail($headers = ''){
$this->headers = $headers;
}
/****************************************
** メールに HTML 部分を追加します。
** また、画像名を
** コンテンツ ID に置き換えます。
**************************************/
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);
}
}
}
/****************************************
** 電子メールの HTML 部分を構築します。
**************************************/
function build_html($orig_boundary){
$sec_boundary = '=_'.md5(uniqid (時間()));
$thr_boundary = '=_'.md5(uniqid(time()));
if(!is_array($this->html_images)){
$this->multipart.= '--'.$orig_boundary."rn";
$this->multipart.= 'Content-Type: multipart/alternative;境界="'.$sec_boundary.""rnrnrn";
$this->multipart.= '--'.$sec_boundary."rn";
$this->multipart.= 'Content-Type: text/plain'."rn";
$this->multipart.= 'Content-Transfer-Encoding: 7bit'."rnrn";
$this->multipart.= $this->html_text."rnrn";
$this->multipart.= '--'.$sec_boundary."rn";
$this->multipart.= 'Content-Type: text/html'."rn";
$this->multipart.= 'Content-Transfer-Encoding: 7bit'."rnrn";
$this->multipart.= $this->html."rnrn";
$this->multipart.= '--'.$sec_boundary."--rnrn";
}else{
$this->multipart.= '--'.$orig_boundary."rn";
$this->multipart.= 'Content-Type: multipart/relative;境界="'.$sec_boundary.""rnrnrn";
$this->multipart.= '--'.$sec_boundary."rn";
$this->multipart.= 'Content-Type: multipart/alternative;境界="'.$thr_boundary.""rnrnrn";
$this->multipart.= '--'.$thr_boundary."rn";
$this->multipart.= 'Content-Type: text/plain'."rn";
$this->multipart.= 'コンテンツ転送エンコーディング: 7 ビット'."rnrn";
$this->multipart.= $this->html_text."rnrn";
$this->multipart.= '--'.$thr_boundary."rn";
$this->multipart.= 'Content-Type: text/html'."rn";
$this->multipart.= 'コンテンツ転送エンコーディング: 7 ビット'."rnrn";
$this->multipart.= $this->html."rnrn";
$this->multipart.= '--'.$thr_boundary."--rnrn";
for($i=0; $i
$this->multipart.= '--'.$sec_boundary."ん";
$this->build_html_image($i);
}
$this->multipart.= "--".$sec_boundary."--rnrn";
}
}
/****************************************
** 画像を埋め込みリストに追加します
** 画像。
**************************************/
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())) );
}
/****************************************
** 添付ファイルのリストにファイルを追加します。
**************************************/
function add_attachment($file, $name = '', $c_type='application/octet-stream'){
$this->parts[] = array( 'body' => $file,
'name' => $name,
'c_type' => $c_type );
}
/*****************************************
** ** HTMLメール。
**************************************/
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'].""rn";
else $this->multipart .= "rn";
$this->multipart.= 'Content-ID: html_images[$i]['cid'].">rn";
$this->multipart.= 'コンテンツ転送エンコーディング: Base64'."rnrn";
$this->multipart.= chunk_split(base64_encode($this->html_images[$i]['body']))."rn";
}
/****************************************
** マルチパートの単一パートを構築します
** メッセージ。
**************************************/
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'].""rn";
else
$message_part .= "rn";
// コンテンツのエンコーディングを決定します。
if($this->parts[$i]['c_type'] == 'text/plain'){
$message_part.= 'Content-Transfer-Encoding: 7bit'."rnrn";
$message_part.= $this->parts[$i]['body']."rn";
}else{
$message_part.= 'コンテンツ転送エンコーディング:base64'."rn";
$message_part.= 'Content-Disposition: 添付ファイル; filename="'.$this->parts[$i]['name'].""rnrn";
$message_part.= chunk_split(base64_encode($this->parts[$i]['body']))."rn";
}
$message_part を返す;
}
/****************************************
** ** リスト ($this->parts)。
**************************************/
function build_message(){
$boundary = '=_'.md5(uniqid(time()));
$this->headers.= "MIME バージョン: 1.0rn";
$this->headers.= "Content-Type: multipart/mixed; border="".$boundary.""rn";
$this->multipart = '';
$this->multipart.= "これは MIME エンコードされたメッセージです。rnCreated by html_mime_mail.class.rnコピーについては http://www.heyes-computing.net/scripts/ を参照してください。rnrn";
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' =>
for($i=(count($this->parts)-1); $i>=0; $i--){
$this->multipart.= '- -'.$boundary."rn".$this->build_part($i);
}
$this->mime = $this->multipart."--".$boundary."--rn";
}
/****************************************
** メールを送信します。
**************************************/
関数 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."rn";
//$this->headers.= $headers;
mail($to, $subject, $this->mime, $this->headers);
}
/****************************************
** 直接 ** SMTP 接続。 Manuel Lemos の
** smtp メール配信クラスに依存しています:
** http://phpclasses.upperdesign.com
**
** void smtp_send( string *Name* of smtpオブジェクト、
** 文字列 From アドレス、
** 配列 To アドレス、
** 配列 ヘッダー、
** 文字列 本体)
********** *****************************/
function smtp_send($smtp_obj, $from_addr, $to_addr){
global $$smtp_obj;
$smtp_obj = $$smtp_obj;
if(substr($this->headers, -2) == "rn") $this->headers = substr($this->headers,0,-2);
$this->headers =explode("rn", $this->headers);
$smtp_obj->sendmessage($from_addr, $to_addr, $this->headers, $this->mime);
}
} // クラス終了。
?>

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 英語版
推奨: Win バージョン、コードプロンプトをサポート!

mPDF
mPDF は、UTF-8 でエンコードされた HTML から PDF ファイルを生成できる PHP ライブラリです。オリジナルの作者である Ian Back は、Web サイトから「オンザフライ」で PDF ファイルを出力し、さまざまな言語を処理するために mPDF を作成しました。 HTML2FPDF などのオリジナルのスクリプトよりも遅く、Unicode フォントを使用すると生成されるファイルが大きくなりますが、CSS スタイルなどをサポートし、多くの機能強化が施されています。 RTL (アラビア語とヘブライ語) や CJK (中国語、日本語、韓国語) を含むほぼすべての言語をサポートします。ネストされたブロックレベル要素 (P、DIV など) をサポートします。

EditPlus 中国語クラック版
サイズが小さく、構文の強調表示、コード プロンプト機能はサポートされていません

SAP NetWeaver Server Adapter for Eclipse
Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

ホットトピック









