ホームページ バックエンド開発 PHPチュートリアル MIME メールを送信するクラス_PHP チュートリアル

MIME メールを送信するクラス_PHP チュートリアル

Jul 13, 2016 pm 05:27 PM
add html mail new t 送信 親切 郵便

画像ファイルが含まれていない場合: $mail = new html_mime_mail() $html ="HTML コンテンツ"; $mail->build_message(); (受信者、受信メール、送信者、送信メール、タイトル、追加ヘッダー);


画像ファイルが含まれる場合: $url="www.cuti.com.my/AD/" //画像ファイルの場所?FONT color =" #007700">} ?FONT color="#007700">} ヘッダーなし http:// と末尾のスラッシュ $path="/MAIL/AD/"; //画像ファイルのパスの末尾にスラッシュがあります$filename1 = a.jpg; $backgrnd1 = fopen($path.$filename1, r), fclose($fp); $filename6 = f .gif; $backgrnd6 = fopen($path.$filename6, r), $mail->add_html_image($); backgrnd1,$ filename1, image/jpeg,http://.$url.$filename1); ...など... $mail->add_html_image($backgrnd6,$filename6,image/gif,http:// .$url .$ filename6); $mail = new html_mime_mail() $html ="画像を含む HTML コンテンツ" $mail->build_message(); >send( 受信者、受信メール、送信者、送信メール、タイトル、追加ヘッダー); } /*************************************** ** タイトル.........: HTML Mime Mail クラス ** バージョン....: 1.26 ** 作成者....: Richard Heyes ** ファイル名....: html_mime_mail.class ** 最終変更日.. : 2000/06/25 ** 注....: Tobias Ratschiller ** と Sascha Schumann による mime_mail.class ** に基づいています。 ** - Win32 用の修正 ** を提供してくれた Thomas Flemming に感謝します。 ** - ヘッダーが LF ではなく CRLF で終了するようになり、** RFC822 に準拠しました。 Pao-Hsi Huang に感謝します。 ** - バグを修正しました。特定のメール システム (特に gmx.net) ** は、境界線の等号の両側 ** にスペース文字があるためにメールを拒否していました。通知してくれた ** Peter Holm に感謝します。 ** - バグを修正しました。 $html_images は配列であるかどうかテストされました ** が、オブジェクトの作成時に配列に設定されたため、** テストは常に true を返しました。 ** 通知してくれた Bob Silva に感謝します。 ** - バグを修正しました。 $obj->send() でループすると、From: ヘッダー ** が蓄積していました。残念だ。 ** 通知してくれた Lance Rasmussen に感謝します。 ** - サンプル スクリプトを含む zip/tar ** については、http://www.heyes-computing.net/scripts/ を参照してください。 **************************************/ class html_mime_mail{ var $headers; var $body; var $multipart; var $mime; var $html; var $html_text; var $html_images = array(); var $parts = array(); { $this->headers = $headers; } /*************************************** ** コンストラクター関数。ヘッダーが指定されている場合は ** を設定します。 **************************************/ function add_html($html, $text){ $this->html = $html; html_text = $text; if(is_array($this->html_images) A​​ND count($this->html_images) > 0){ /* for($i=0; $ihtml_images){ $this - > html = ereg_replace($this->html_images[$i][名前], cid:.$this->html_images[$i][cid], $this->html); } */ } } /** ************************************* ** メールに HTML 部分を追加します。 ** また、画像名を ** コンテンツ ID に置き換えます。 **************************************/ function build_html($orig_boundary){ $sec_boundary = =_.md5(uniqid(time())); $thr_boundary = =_.md5(uniqid(time())); > html_images) == 0){ $this->multipart.= --.$orig_boundary " "; $this->multipart.= Content-Type: multipart/alternative;.chr(10).chr(9).boundary=".$sec_boundary "" "; // $this->multipart.= --.$thr_boundary の下に ttj を追加します。 " "; $this->multipart.= Content-Type: text/plain." "; $this->multipart.= $this->html_text. " "; $this->multipart.= --.$thr_boundary. "-- "; // ttj が $this->multipart.= --.$sec_boundary の上に追加されました。 " "; $this->multipart.= Content-Type: text/plain." "; $this->multipart.= コンテンツ転送エンコーディング: Base64。" "; $this->multipart.= chunk_split(base64_encode($this->html_text))。" "; // $this->multipart.= --.$thr_boundary の下に ttj を追加します。 " "; $this->multipart.= Content-Type: text/html. " "; $this->multipart.= $this->html. " "; $this->multipart.= --.$thr_boundary. "-- "; // ttj が $this->multipart.= --.$sec_boundary の上に追加されました。 " "; $this->multipart.= Content-Type: text/html. " "; $this->multipart.= コンテンツ転送エンコーディング: Base64。" "; $this->multipart.= chunk_split(base64_encode($this->html))." "; $this->multipart.= --.$sec_boundary. "-- "; }else{ $this->multipart.= --.$orig_boundary. 」 "; $this->multipart.= Content-Type: multipart/relative;.chr(10).chr(9).boundary=".$sec_boundary. 「」 "; $this->multipart.= --.$sec_boundary. " "; $this->multipart.= Content-Type: multipart/alternative;.chr(10).chr(9).boundary=".$thr_boundary. 「」 "; $this->multipart.= --.$thr_boundary. " "; $this->multipart.= Content-Type: text/plain." "; $this->multipart.= コンテンツ転送エンコーディング: Base64。" "; $this->multipart.= chunk_split(base64_encode($this->html_text))。" "; // $this->multipart.= --.$thr_boundary の下に ttj を追加します。 " "; $this->multipart.= Content-Type: text/html. " "; $this->multipart.= $this->html. " "; $this->multipart.= --.$thr_boundary. "-- "; // ttj が $this->multipart.= --.$thr_boundary の上に追加されました。 " "; $this->multipart.= Content-Type: text/html. " "; $this->multipart.= コンテンツ転送エンコーディング: Base64。" "; $this->multipart.= chunk_split(base64_encode($this->html))。" "; $this->multipart.= --.$thr_boundary. "-- "; for($i=0; $ihtml_images); $i++){ $this->multipart.= --.$sec_boundary. " "; $this->build_html_image($i); } $this->multipart.= "--".$sec_boundary. "-- "; } } /*************************************** ** 埋め込まれた ** 画像のリストに画像を追加します。 **************************************/ function add_html_image($file, $name = , $c_type= application/octet-stream, $location= ){ $this->html_images[] = array( body => $ファイル、名前 => $name、c_type => $c_type、場所 => $location、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 ); / 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][名前]。 「」 "; else $this->multipart .= " "; $this->multipart.= コンテンツ転送エンコーディング: Base64。" "; $this->multipart.= Content-Location:.$this->html_images[$i][location]. " "; $this->multipart.= コンテンツ ID: <.>html_images[$i][cid]. "> "; $this->multipart.= chunk_split(base64_encode($this->html_images[$i][body]))." "; } /*************************************** ** ** HTML メールの埋め込み画像部分を構築します。 **************************************/ function build_part($i){ $message_part = ; $message_par

www.bkjia.comtru​​ehttp://www.bkjia.com/PHPjc/531886.html技術記事結果不含圖檔: $mail = new html_mime_mail(); $html =HTML內容; $mail->add_html($html, $text); $mail->build_message(); $mail->send(收信人,收信Email,發信人,發信Email,標...
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

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

AI Clothes Remover

AI Clothes Remover

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

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

Video Face Swap

Video Face Swap

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

ホットツール

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)

HTMLの表の境界線 HTMLの表の境界線 Sep 04, 2024 pm 04:49 PM

HTML の表の境界線に関するガイド。ここでは、HTML でのテーブルの境界線の例を示しながら、テーブル境界線を定義する複数の方法について説明します。

HTML のネストされたテーブル HTML のネストされたテーブル Sep 04, 2024 pm 04:49 PM

これは、HTML でのネストされたテーブルのガイドです。ここでは、テーブル内にテーブルを作成する方法をそれぞれの例とともに説明します。

HTML 左マージン HTML 左マージン Sep 04, 2024 pm 04:48 PM

HTML マージン左のガイド。ここでは、HTML margin-left の概要とその例、およびそのコード実装について説明します。

HTML テーブルのレイアウト HTML テーブルのレイアウト Sep 04, 2024 pm 04:54 PM

HTML テーブル レイアウトのガイド。ここでは、HTML テーブル レイアウトの値と例および出力について詳しく説明します。

HTML入力プレースホルダー HTML入力プレースホルダー Sep 04, 2024 pm 04:54 PM

HTML 入力プレースホルダーのガイド。ここでは、コードと出力とともに HTML 入力プレースホルダーの例について説明します。

PHPでHTML/XMLを解析および処理するにはどうすればよいですか? PHPでHTML/XMLを解析および処理するにはどうすればよいですか? Feb 07, 2025 am 11:57 AM

このチュートリアルでは、PHPを使用してXMLドキュメントを効率的に処理する方法を示しています。 XML(拡張可能なマークアップ言語)は、人間の読みやすさとマシン解析の両方に合わせて設計された多用途のテキストベースのマークアップ言語です。一般的にデータストレージに使用されます

HTML 順序付きリスト HTML 順序付きリスト Sep 04, 2024 pm 04:43 PM

HTML 順序付きリストのガイド。ここでは、HTML 順序付きリストと型の導入とその例についても説明します。

HTML の onclick ボタン HTML の onclick ボタン Sep 04, 2024 pm 04:49 PM

HTML オンクリック ボタンのガイド。ここでは、それらの紹介、動作、例、およびさまざまなイベントでの onclick イベントについてそれぞれ説明します。

See all articles