Il mio script email multipart invia i messaggi HTML bene, ma la pianura alternativa testo non dovesse funzionare, ciò che può essere sbagliato?

StackOverflow https://stackoverflow.com/questions/2629767

Domanda

Ho uno script impostato per inviare email a più parti; testo e HTML messaggi semplici. I messaggi HTML funzionano bene, ma quando ho usato un client di posta elettronica che solo fa testo normale il messaggio di testo lamento non esegue il rendering e ottengo il seguente:

  

-
  Questo messaggio è stato generato automaticamente da Me
   http://www.somewebsite.com/


$html_msg = $message_details;
$plain_text_msg = strip_tags($message_details);

$headers = <<<HEADERS
From: Me <info@somewebsite.com>
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="==PHP-alt$mime_boundary"
HEADERS;

// Use our boundary string to create plain text and HTML versions
$message = <<<MESSAGE

--==PHP-alt$mime_boundary
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

$plain_text_msg

--
This message was generated automatically by Me
http://www.somewebsite.com/

If you did not request this message, please notify promotions@mewstavern.com

--==PHP-alt$mime_boundary
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit 
<html>
<body>
$html_msg
<p>
--<br />
This message was generated automatically as a demonstration on
<a href="http://www.somewebsite.com/">Me</a>
</p>
<p>
If you did not request this message, please notify 
<a href="mailto:info@somewebsite.com">info@somewebsite.com</a>
</p>
</body>
</html>
--==PHP-alt$mime_boundary--
MESSAGE;
È stato utile?

Soluzione

Il problema è lo spazio bianco nella sintassi heredoc sto usando. Esso non è rappresentato nell'esempio precedente.

@ qor72 grazie per il vostro input.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top