添付ファイル付きのメールをmicrosoft exchange serverに送る機能があります。私の問題は、添付ファイルを追加するときは、メッセージ全体が添付ファイルのソースにテキストを追加することです。添付ファイルをメールの本文セクションに保存すると、添付ファイルを作成するのではなく、添付ファイルのソースが電子メール本文に書き込まれます。 Beloweは私の情報源です。php経由でメールをMicrosoft Exchangeに送る
$eol = "\r\n";
$boundary = md5(time());
$mail = "[email protected]";
$headers = "From: [email protected]".$eol;
$headers .= "MIME-Version: 1.0".$eol; //utworzenie headera wiadomosci
$headers .= "Content-type: multipart/alternative; charset=utf-8".$eol;
$headers .= "Message-ID:< [email protected]".$_SERVER['SERVER_NAME'].">".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol;
$headers .= 'MIME-Version: 1.0'.$eol;
$headers .= "Content-Type: multipart/related; boundary=\"".$boundary."\"".$eol;
$headers .= "--$boundary".$eol;
$headers .= "Content-Type: text/plain; charset=utf-8".$eol;
$headers .= "Content-Transfer-Encoding: 8bit".$eol;
$headers .= "--$boundary--".$eol.$eol;
if ($file != ''){
$handle = fopen($file['tmp_name'], 'rb');
$f_content = fread($handle, $file['size']);
$attachment = chunk_split(base64_encode($f_content));
fclose($handle);
$content .= "--$boundary".$eol;
$content .= "Content-type: ".$file['type'].'; '.'name="'.$file['name'].'"'.$eol;
$content .= 'Content-Disposition: attachment; filename="'.$file['name'].'"'.$eol.$eol;
$content .= "Content-Transfer-Encoding: base64".$eol;
$content .= $attachment.$eol.$eol;
$content .= "--$boundary--".$eol.$eol;
}
mail($mail, 'title', $content, $headers)
私はすべてを試しましたが、何も私のために働くと思います。 :(
あなたは本当にSwiftMailerのようなライブラリを使うべきです。 HTML電子メールを送信することは解決された問題です。 – ceejayoz
梨のメールパッケージはあなたの人生を楽にします。 http://pear.php.net/package/Mail – Zac