phpメールクラス、phpメール
phpソケットを使用してメールを送信するクラスを作成します。phpプログラムを使用してメールを送信する場合は、シンプルで使いやすいです。
163 サーバーでは、RCPT コマンドで 163 メールボックスが存在するかどうかを確認することもできます。さまざまな用途があります。
まだ考えてません。記録して、困っている友達が参照できるようにします
クラスメール {
/**
*メールで送信できます
*/
public $host;
public $port;
public $user;
public $password;
public $mail_form;
public $rcpt;
public $body;
/**
*ヘッダーに添付されている情報
*/
public $to_name;
public $from_name;
public $subject;
public $html;
public $connection;
public $msg = array() ;
// 実行パラメータ初期化
public function __construct($conf, $rcpt, $header, $body, $html = true) {
try {
$this->host = $conf['host '];
$this->port = $conf['port'];
$this->user = $conf['user'];
$this->password = $conf['password'] ;
$this->rcpt = $rcpt;
$this->to_name = $header['to_name'];
$this->from_name = $header['from_name'];
$this- >subject = $header['subject'];
$this->html = $html;
$this->body =base64_encode($body);
} catch (Exception $e) {
投げる新しい例外($e->getMessage());
}
}
public function connect() {
$this->connection = @fsockopen($this->host, '25', $errno, $errstr, 10);
if (! $this->connection) {
throw new Exception('connect failed!');
}
$greet = $this->callback_code();
}
パブリック関数 helo() {
if($ this->is_connect() &&
$this->send_data('HELO ' . $this->host) &&
$this->callback_code() == 250
{
) true を返す;
} else {
throw new Exception($this->get_callback_msg_lastest());
}
}
public function send_data($cmd) {
if (is_resource($this) ->接続)) {
return @fwrite( $this->connection, $cmd."rn", strlen($cmd) + 2);
}
}
public function auth(){
if ($this->is_connect() &&
$this ->send_data('AUTH LOGIN') && $this->callback_code() == 334 &&
$this->send_data(base64_encode($this->user)) && $this->callback_code() == 334 &&
$this->send_data(base64_encode($this->password)) && $ this->callback_code() == 235 ) {
return true;
} else {
throw new Exception($this->get_callback_msg_lastest());
}
}
public function Mail() {
if ($this->is_connect() &&
$this->send_data("MAIL FROM:user& gt;") &&
$this->callback_code() == 250
) {
return true;
} else {
throw new Exception($this->get_callback_msg_lastest());
}
}
パブリック関数 is_connect() {
return is_resource($this->connection);
}
パブリック関数 callback_code() {
if ($this->is_connect()) {
$msg = fgets($this->connection);
if (!empty($msg)) {
$code = substr($msg, 0, strpos($msg, ' '));
} else {
戻る ' ';
}
$this->msg[] = $msg;
return $code;
}
}
public function get_callback_msg_lastest() {
return end($this->msg);
}
public function rcpt($rcpt) {
if ($this->is_connect() &&
$this->send_data("RCPT TO:") &&
$this->callback_code() = = 250
) {
return true;
} else {
throw new Exception($this->get_callback_msg_lastest());
}
}
パブリック関数 data() {
if ($this->is_connect() &&
$this->send_data('DATA') &&
$this->call back_code() == 354) {
return true;
} else {
throw new Exception($this->get_callback_msg_lastest());
}
}
public function send_mail() {
試してみてください {
$this->connect();
$this->helo();
$this->auth();
$this->Mail();
if (is_array($this) -> rcpt)) {
foreach ($this->rcpt as $rcpt) {
$this->rcpt($rcpt);
}
} else {
$this->rcpt($this-> rcpt);
}
$this->data();
$header = str_replace("rn" . '.', "rn" . '..', トリム(implode("rn", $this ->get_header())));
$body = str_replace("rn" . '.', "rn" . '..', $this->body);
$body = substr($body, 0, 1) == '.' ? 「。」 。 $body : $body;
$this->send_data($header);
$this->send_data('');
$this->send_data($body);
$this->send_data('.');
if ($this->callback_code() != 250) {
throw new Exception('メール送信失敗!');
}
return true;
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
}
//ただ能检测同じ邮件服务器上のメールアドレス
public function is_email_exist() {
}
パブリック関数 get_header() {
$header = array( );
$content_type = $this->html ? 'テキスト/html;' : 'テキスト/プレーン;' ;
$headers [] = '日付: ' 。 gmdate('D, j M Y H:i:s') 。 ' +0000';
$to_mail = is_array($this->rcpt) ? implode(',', $this->rcpt) : $this->rcpt;
$headers [] = 'To: "' . '=? utf8?B?' .base64_encode($this->to_name) .'" ';
$headers [] = 'From: "' . '=?utf8?B?' .base64_encode($this->from_name) .'" ユーザー 。 '>';
$headers [] = '件名: ' 。 '=?utf8?B?' 。 Base64_encode($this->subject) 。 '?=';
$headers [] = 'Content-Type:'.$content_type 。 ' 文字セット=utf8; format=flowed';
$headers [] = 'Content-Transfer-Encoding:base64';
$headers [] = 'Content-Disposition: inline';
return $headers;
}
}
/**
* 関数を使用してクラスをカプセル化する
*/
function send_mail($conf, $rcpt, $header, $body) {
$mail = new mail($conf, $rcpt, $header, $body);
if ($mail->send_mail()) {
echo 'メールを正常に送信しました!';
} else {
echo '失敗しました!';
}
}
$conf = array(
'host' => 'smtp.163.com',
'port' => '25',
'user' => 'z1298703836@163.com',
'パスワード' => 'zeiwei123',
);
$rcpt = array(
'z1298703836@sina.com',
'wei.zen@baisonmail.com '
);
$header = array(
'to_name' => 'willstang',
'from_name' => 'sinawill',
'subject' => 'tst of reo ',
);
$body = '
sfsfsd
';$mail = 新規メール($conf, $rcpt, $header, $body);
$mail ->send_mail();
echo '
';<br>print_r($mail->msg); <p> </p> <p>電子メールの送信プロセスとその stmp プロトコルについてよく理解してください </p> <p>送信内容は 2 つの部分に分かれており、1 つの部分はヘッダーにあり、もう 1 つの部分はメールの本文であるなど、送信の詳細もいくつかあります。 </p><p></p> <p align="left"></p><div style="display:none;">http://www.bkjia.com/PHPjc/965030.html<span id="url" itemprop="url"></span>www.bkjia.com<span id="indexUrl" itemprop="indexUrl"></span>true<span id="isOriginal" itemprop="isOriginal"></span>http://www.bkjia.com/PHPjc/965030.html<span id="isBasedOnUrl" itemprop="isBasedOnUrl"></span>技術記事<span id="genre" itemprop="genre"></span> phpメールクラス、phpメールはphpソケットを使用してメールを送信するクラスを作成します。phpプログラムを使用してメールを送信する場合、163サーバーではRCPTコマンドで確認できます。 <span id="description" itemprop="description"></span> </div>

まだ人気があるのは、使いやすさ、柔軟性、強力なエコシステムです。 1)使いやすさとシンプルな構文により、初心者にとって最初の選択肢になります。 2)Web開発、HTTP要求とデータベースとの優れた相互作用と密接に統合されています。 3)巨大なエコシステムは、豊富なツールとライブラリを提供します。 4)アクティブなコミュニティとオープンソースの性質は、それらを新しいニーズとテクノロジーの傾向に適応させます。

PHPとPythonはどちらも、Web開発、データ処理、自動化タスクで広く使用されている高レベルのプログラミング言語です。 1.PHPは、ダイナミックウェブサイトとコンテンツ管理システムの構築によく使用されますが、PythonはWebフレームワークとデータサイエンスの構築に使用されることがよくあります。 2.PHPはエコーを使用してコンテンツを出力し、Pythonは印刷を使用します。 3.両方ともオブジェクト指向プログラミングをサポートしますが、構文とキーワードは異なります。 4。PHPは弱いタイプの変換をサポートしますが、Pythonはより厳しくなります。 5. PHPパフォーマンスの最適化には、Opcacheおよび非同期プログラミングの使用が含まれますが、PythonはCprofileおよび非同期プログラミングを使用します。

PHPは主に手順プログラミングですが、オブジェクト指向プログラミング(OOP)もサポートしています。 Pythonは、OOP、機能、手続き上のプログラミングなど、さまざまなパラダイムをサポートしています。 PHPはWeb開発に適しており、Pythonはデータ分析や機械学習などのさまざまなアプリケーションに適しています。

PHPは1994年に発信され、Rasmuslerdorfによって開発されました。もともとはウェブサイトの訪問者を追跡するために使用され、サーバー側のスクリプト言語に徐々に進化し、Web開発で広く使用されていました。 Pythonは、1980年代後半にGuidovan Rossumによって開発され、1991年に最初にリリースされました。コードの読みやすさとシンプルさを強調し、科学的コンピューティング、データ分析、その他の分野に適しています。

PHPはWeb開発と迅速なプロトタイピングに適しており、Pythonはデータサイエンスと機械学習に適しています。 1.PHPは、単純な構文と迅速な開発に適した動的なWeb開発に使用されます。 2。Pythonには簡潔な構文があり、複数のフィールドに適しており、強力なライブラリエコシステムがあります。

PHPは、多数のWebサイトとアプリケーションをサポートし、フレームワークを通じて開発ニーズに適応するため、近代化プロセスで依然として重要です。 1.PHP7はパフォーマンスを向上させ、新機能を紹介します。 2。Laravel、Symfony、Codeigniterなどの最新のフレームワークは、開発を簡素化し、コードの品質を向上させます。 3.パフォーマンスの最適化とベストプラクティスは、アプリケーションの効率をさらに改善します。

phphassiblasifly-impactedwebdevevermentandsbeyondit.1)itpowersmajorplatformslikewordpratsandexcelsindatabase interactions.2)php'sadaptableability allowsitale forlargeapplicationsusingframeworkslikelavel.3)

PHPタイプは、コードの品質と読みやすさを向上させるためのプロンプトがあります。 1)スカラータイプのヒント:php7.0であるため、基本データ型は、int、floatなどの関数パラメーターで指定できます。 3)ユニオンタイプのプロンプト:PHP8.0であるため、関数パラメーターまたは戻り値で複数のタイプを指定することができます。 4)Nullable Typeプロンプト:null値を含めることができ、null値を返す可能性のある機能を処理できます。


ホットAIツール

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

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

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

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

MinGW - Minimalist GNU for Windows
このプロジェクトは osdn.net/projects/mingw に移行中です。引き続きそこでフォローしていただけます。 MinGW: GNU Compiler Collection (GCC) のネイティブ Windows ポートであり、ネイティブ Windows アプリケーションを構築するための自由に配布可能なインポート ライブラリとヘッダー ファイルであり、C99 機能をサポートする MSVC ランタイムの拡張機能が含まれています。すべての MinGW ソフトウェアは 64 ビット Windows プラットフォームで実行できます。

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

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

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境
