[PHP-users 24869] Re: PEAR::Mail で添付ファイル付きメールが送れません。

古川敦史 agl @ violet.plala.or.jp
2005年 3月 14日 (月) 22:48:47 JST


古川です。
ちょっと問題が違うところに発散しているようなので、整理します。

前提:
PEAR::MailおよびPEAR::Mail_mimeクラスを使って添付ファイルつきメールを送ろうとしている

現象:
開発環境がわであるこちらのメーラー(Outlook 2000,Outlook Express, 電信八号)では正常に
添付ファイルつきmaleとして送信されるが、
クライアント側ではヘッダーが切れ、ヘッダーつきテキストで文章全体がテキストとして表示される。

テスト用のメール送信プログラムは次のとおり

|<?php
|require_once 'Mail.php';
|require_once 'Mail/mime.php';
|
|if (isset($_POST['to'])) {
|  
|  $message = "テストメール";
|  $attach = mb_convert_kana("添付データ", 'k');
|  $mail = new Mail();
|  $mime = new Mail_mime();
|  $mime->setSubject(mb_encode_mimeheader('テストメール'));
|  $mime->setFrom(mb_encode_mimeheader('テスタ') . ' <test @ agartha.private>');
|  $mime->setTxtBody(mb_convert_encoding($message, 'jis'));
|  $c_type = 'text/plain; name="test.txt"';
|  $mime->addAttachment($attach, $c_type, 'test.txt', false);
|  $body = $mime->get(array('text_charset' => 'iso-2022-jp'));
|  
|  $headers = $mime->headers();
|  $mail->send($_POST['to'], $headers, $body);
|?>

メールは以下のようになります。
改行コード以外は問題ない感じなんですが

-----
|Delivered-To: m23000000-sp @ turiken.com
|Received: (qmail 2275 invoked by SAV 20050313.041); 14 Mar 2005 22:22:50
|+0900
|Date: 14 Mar 2005 22:22:50 +0900
|Message-ID: <20050314132250.2273.qmail @ ps18.suite2.arena.ne.jp>
|To: sp @ turiken.com
|Subject: =?ISO-2022-JP?B?GyRCJUYlOSVIJWEhPCVrGyhC?=
|MIME-Version: 1.0 
|
|From: =?ISO-2022-JP?B?GyRCJUYlOSU/GyhC?= <test @ agartha.private>
|Content-Type: multipart/mixed;
|
|	boundary="=_a3626347747c82e116afce671498aaaa"
|
|
|--=_a3626347747c82e116afce671498aaaa
|
|Content-Type: text/plain; charset="iso-2022-jp"
|
|Content-Transfer-Encoding: 7bit
|
|
|テストメール
|
|--=_a3626347747c82e116afce671498aaaa
|
|Content-Type: text/plain; name="test.txt"
|
|Content-Transfer-Encoding: base64
|
|Content-Disposition: attachment; filename="test.txt"
|
|
|
|k1mVdMPesMA=
|
|--=_a3626347747c82e116afce671498aaaa--
---- ここまで

以上です。

-- /Private
PHPlibrary "aglib" http://aglib.sourceforge.jp で公開中
//Furukawa Atsushi / 古川 敦史
E-Mail: agl @ violet.plala.or.jp
MOBILE: 090-6959-6225
FAX: 020-4622-3018
HomePage: http://www.aglabo.com/agl/
		  http://www.furukawa-select.com/mt/



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.7.2 - Release Date: 2005/03/11



PHP-users メーリングリストの案内