Сценарий электронной почты php не создает версию HTML или расширение вложения. что пошло не так? - PullRequest
0 голосов
/ 31 января 2012

вот (все) код:

<?php
/*

            WHITE SPACE MATTERS IN THIS DOCUMENT

*/
include("_php/ChromePhp.php");
    // define receiver of email
$to = "person@place.com";
    // define subject of email
$subject = "<--== KABAM!  HTML Email from WR! ==-->";
    // define message to send.  use /n for linebreaks
//$message = 'This is the message.  Read it.  Love it.';
    // create a boundary string.  it must be unique!
$uniqID = md5(date('r', time()));
    // define the headers. separated by \r\n
$headers = "From: some dude" . "\r\n";
$headers .= "Reply-To: nobody" . "\r\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"PHP-mixed-".$uniqID."\""."\r\n";
    // read the attachment into a string, encode it and then
    // split it into smaller chunks
$attachment = chunk_split(base64_encode(file_get_contents('./_dox/pdftmp/emailTESTER.zip')));
    // define the body of the message
ob_start(); // turn on output buffering
?>
--PHP-mixed-<?php print $uniqID; ?>
Content-Type: multipart/alternative; boundary="PHP-alt-<?php print $uniqID; ?>

--PHP-alt-<?php print $uniqID; ?>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

This is the TEXT email.
Nothing but pure text.  not really fun...

--PHP-alt-<?php print $uniqID; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

<h1>This is the HTML test email.</h1>
<h3>Read it.  Love it.</h3>
<p>this is all HTML.  without any CSS, mind you...</p>

<?php include("_php/formEmail.php"); ?>

--PHP-alt-<?php print $uniqID; ?>--

--PHP-mixed-<?php print $uniqID; ?>
Content-Type: application/zip; name="emailTESTER.zip"
Content-Transfer-Encoding: base64
Content-Disposition: attachment

<?php print $attachment; ?>
--PHP-mixed-<?php print $uniqID; ?>--

<?php
    // copy current buffer contents into $message then delete
    // the contents of the output buffer
$message = ob_get_clean();
    // send the email
$mail_sent = @mail($to, $subject, $message, $headers);
    // display a message depending on mail_sent status
print  $mail_sent ? "Mail Sent: ".$uniqID : "Mail Failed: ".$uniqID;
?>

и вот что выскакивает в почтовом клиенте: (не рендерится ...)

This is the TEXT email.
Nothing but pure text.  not really fun...

--PHP-alt-a0d18dbf6c6ec8fb30c47adc84234c75Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

<h1>This is the HTML test email.</h1>
<h3>Read it.  Love it.</h3>
<p>this is all HTML.  without any CSS, mind you...</p>


--PHP-alt-a0d18dbf6c6ec8fb30c47adc84234c75--

вложение, вместо «emailTESTER.zip», просто «часть 2» и не является расширением. если я добавлю «.zip», он станет правильным архивом (хотя и не названным) с правильным содержимым ...

Я трижды проверил граничные линии, я считаю, что они правильно установлены. единственное, о чем я мог подумать, это что-то в объявлениях Content-Type ... но если это так, я не знаю, что это могло бы быть ... я прочитал все предыдущие посты на "PHP email HTML бла-бла ", и, хотя они дали понимание, никто из них не коснулся моей странной пары икоты. НАРФ

так. Что я упустил? почему он не работает правильно / полностью?

ТИА.

WR!

1 Ответ

1 голос
/ 31 января 2012

Не изобретай велосипед.Используйте существующий почтовый класс. PHPMailer отлично.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...