ソース掲示板




すべてから検索

キーワード   条件 表示 現行ログ 過去ログ トピックス 名前 本文
2013 年 : Pear インストール / Mail パッケージと実行サンプル( GMail でメール送信 )
日時: 2013/11/03 20:08
名前: lightbox



▼ まずこれをダウンロードして、php フォルダにコピー
http://pear.php.net/go-pear.phar

▼ php.ini の変更
php.ini
拡張子:
include_path=".;C:\php\pear\"

extension=php_openssl.dll
▼ 実行
C:\php>php go-pear.phar

Are you installing a system-wide PEAR or a local copy?
(system|local) [system] : no
Please confirm local copy by typing 'yes' : yes

Below is a suggested file layout for your new PEAR installation.  To
change individual locations, type the number in front of the
directory.  Type 'all' to change all of them or simply press Enter to
accept these locations.

 1. Installation base ($prefix)                   : C:\php
 2. Temporary directory for processing            : C:\php\tmp
 3. Temporary directory for downloads             : C:\php\tmp
 4. Binaries directory                            : C:\php
 5. PHP code directory ($php_dir)                 : C:\php\pear
 6. Documentation directory                       : C:\php\docs
 7. Data directory                                : C:\php\data
 8. User-modifiable configuration files directory : C:\php\cfg
 9. Public Web Files directory                    : C:\php\www
10. Tests directory                               : C:\php\tests
11. Name of configuration file                    : C:\php\pear.ini
12. Path to CLI php.exe                           : C:\php

1-12, 'all' or Enter to continue:

Beginning install...
Configuration written to C:\php\pear.ini...
Initialized registry...
Preparing to install...
installing phar://C:/php/go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.3.11.t
ar...
installing phar://C:/php/go-pear.phar/PEAR/go-pear-tarballs/Console_Getopt-1.3.1
.tar...
installing phar://C:/php/go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.9.4.tar...
installing phar://C:/php/go-pear.phar/PEAR/go-pear-tarballs/Structures_Graph-1.0
.4.tar...
installing phar://C:/php/go-pear.phar/PEAR/go-pear-tarballs/XML_Util-1.2.1.tar..
.
install ok: channel://pear.php.net/Archive_Tar-1.3.11
install ok: channel://pear.php.net/Console_Getopt-1.3.1
install ok: channel://pear.php.net/Structures_Graph-1.0.4
install ok: channel://pear.php.net/XML_Util-1.2.1
install ok: channel://pear.php.net/PEAR-1.9.4
PEAR: Optional feature webinstaller available (PEAR's web-based installer)
PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)

PEAR: To install optional features use "pear install pear/PEAR#featurename"

** WARNING! Old version found at C:\php, please remove it or be sure to use the
new c:\php\pear.bat command

The 'pear' command is now at your service at c:\php\pear.bat

** The 'pear' command is not currently in your PATH, so you need to
** use 'c:\php\pear.bat' until you have added
** 'C:\php' to your PATH environment variable.

Run it without parameters to see the available actions, try 'pear list'
to see what packages are installed, or 'pear help' for help.

For more information about PEAR, see:

  http://pear.php.net/faq.php
  http://pear.php.net/manual/

Thanks for using go-pear!


一応チャネルを更新する C:\php>pear channel-update pear.php.net Updating channel "pear.php.net" Channel "pear.php.net" is up to date
現在インストールされているパッケージ C:\php>pear list INSTALLED PACKAGES, CHANNEL PEAR.PHP.NET: ========================================= PACKAGE VERSION STATE Archive_Tar 1.3.11 stable Console_Getopt 1.3.1 stable PEAR 1.9.4 stable Structures_Graph 1.0.4 stable XML_Util 1.2.1 stable
欲しいパッケージを検索 C:\php>pear search Mail Retrieving data...0% ....50%...MATCHED PACKAGES, CHANNEL PEAR.PHP.NET: ======================================= PACKAGE STABLE/(LATEST) LOCAL Mail 1.2.0 (stable) Class that provides multiple interfaces for sending emails Mail_IMAP 1.1.0RC2 (beta) Provides a c-client backend for webmail. Mail_IMAPv2 0.2.1 (beta) Provides a c-client backend for webmail. Mail_Mbox 0.6.3 (beta) Read and modify Unix MBOXes Mail_Mime 1.8.8 (stable) Mail_Mime provides classes to create MIME messages. Mail_mimeDecode 1.5.5 (stable) Provides a class to decode mime messages. Mail_Queue 1.2.7 (stable) Class for put mails in queue and send them later in background. Net_Vpopmaild 0.3.2 (beta) Class for accessing Vpopmail's vpopmailddaemon Services_Mailman 0.1.0 (beta) Integrates Mailman into a website using PHP
依存するパッケージをインストール C:\php>pear install -f -a -o Mail WARNING: "pear/Auth_SASL" is deprecated in favor of "pear/Auth_SASL2" downloading Mail-1.2.0.tgz ... Starting to download Mail-1.2.0.tgz (23,214 bytes) ........done: 23,214 bytes downloading Net_SMTP-1.6.2.tgz ... Starting to download Net_SMTP-1.6.2.tgz (13,077 bytes) ...done: 13,077 bytes downloading Net_Socket-1.0.14.tgz ... Starting to download Net_Socket-1.0.14.tgz (5,600 bytes) ...done: 5,600 bytes downloading Auth_SASL-1.0.6.tgz ... Starting to download Auth_SASL-1.0.6.tgz (9,119 bytes) ...done: 9,119 bytes install ok: channel://pear.php.net/Mail-1.2.0 install ok: channel://pear.php.net/Net_Socket-1.0.14 install ok: channel://pear.php.net/Auth_SASL-1.0.6 install ok: channel://pear.php.net/Net_SMTP-1.6.2
インストール結果を確認 C:\php>pear list INSTALLED PACKAGES, CHANNEL PEAR.PHP.NET: ========================================= PACKAGE VERSION STATE Archive_Tar 1.3.11 stable Auth_SASL 1.0.6 stable Console_Getopt 1.3.1 stable Mail 1.2.0 stable Net_SMTP 1.6.2 stable Net_Socket 1.0.14 stable PEAR 1.9.4 stable Structures_Graph 1.0.4 stable XML_Util 1.2.1 stable
メンテナンス

GMail でメール送信 ( No.1 )
日時: 2013/11/03 02:39
名前: lightbox


日時: 2013/11/03 02:39
名前: lightbox
拡張子:
<?php
error_reporting(E_ALL ^ E_NOTICE ^ E_STRICT);
require_once("Mail.php");

mb_language("ja");
mb_internal_encoding("UTF-8");

// SMTP 接続設定
$settings = array(
	"host"		=> "ssl://smtp.gmail.com",
	"port"		=> "465",
	"auth"		=> true,
	"username"	=> "ユーザ名",
	"password"	=> "パスワード",
	"debug"		=> true
);

$to_address = "宛先のメールアドレス";
$from_address = "ユーザ名@gmail.com";

$subject = "Gmail(SSL/465)を使ってPHPでメールを送る";
$subject = mb_encode_mimeheader( mb_convert_encoding($subject,"iso-2022-jp") );

$to_header =  mb_encode_mimeheader( mb_convert_encoding("宛先","iso-2022-jp") ) . " <{$to_address}>";
$from_header =  mb_encode_mimeheader( mb_convert_encoding("差出人","iso-2022-jp") ) . " <{$from_address}>";

// メールヘッダー
$headers = array(
	"To"		=> $to_header,
	"From"		=> $from_header,
	"Subject"	=> $subject
);

$body="本文";
$body = mb_convert_encoding($body,"iso-2022-jp");

$smtp = Mail::factory("smtp", $settings);

// 送信
$result = $smtp->send(
		$to_address,
		$headers,
		$body );

if ( PEAR::isError($result) ) {
	print "メール送信エラー:" . $result->getMessage();
}

?>
OK
このアーティクルの参照用URLをクリップボードにコピー メンテナンス
デバッグトレース ( No.2 )
日時: 2013/11/03 02:50
名前: lightbox
DEBUG: Recv: 220 mx.google.com ESMTP kd1sm21040543pab.20 - gsmtp
DEBUG: Send: EHLO localhost

DEBUG: Recv: 250-mx.google.com at your service, [58.0.13.87]
DEBUG: Recv: 250-SIZE 35882577
DEBUG: Recv: 250-8BITMIME
DEBUG: Recv: 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN
DEBUG: Recv: 250-ENHANCEDSTATUSCODES
DEBUG: Recv: 250 CHUNKING
DEBUG: Send: AUTH LOGIN

DEBUG: Recv: 334 VXNlcm5hbWU6
DEBUG: Send: ZG91bWlwbHVz

DEBUG: Recv: 334 UGFzc3dvcmQ6
DEBUG: Send: aXNlaWZ1NTUh

DEBUG: Recv: 235 2.7.0 Accepted
DEBUG: Send: MAIL FROM:<????????@gmail.com>

DEBUG: Recv: 250 2.1.0 OK kd1sm21040543pab.20 - gsmtp
DEBUG: Send: RCPT TO:<????????@nifty.com>

DEBUG: Recv: 250 2.1.5 OK kd1sm21040543pab.20 - gsmtp
DEBUG: Send: DATA

DEBUG: Recv: 354  Go ahead kd1sm21040543pab.20 - gsmtp
DEBUG: Send: To: =?ISO-2022-JP?B?GyRCMDhAaBsoQg==?= <????????@nifty.com>
From: =?ISO-2022-JP?B?GyRCOjk9UD9NGyhC?= <????????@gmail.com>
Subject: =?ISO-2022-JP?B?R21haWwoU1NMLzQ2NSkbJEIkcjtIJEMkRhsoQlBIUBskQiRHJWEhPCVr?=
 =?ISO-2022-JP?B?JHJBdyRrGyhC?=

$BK\J8(B
DEBUG: Send: 
.

DEBUG: Recv: 250 2.0.0 OK 1383414312 kd1sm21040543pab.20 - gsmtp
DEBUG: Send: QUIT

DEBUG: Recv: 221 2.0.0 closing connection kd1sm21040543pab.20 - gsmtp
OK
このアーティクルの参照用URLをクリップボードにコピー メンテナンス