PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : PHP-generierte Mail mit ! mitten im Text


Lyka
2008-04-02, 20:38:41
Hallo,

wir sind in der Firma gerade dran, unsere Emails, die aus dem System via PHP generiert werden, zu erneuern und nun ist uns aufgefallen, daß mitten im Text mehrfach Leerzeichen auftauchen. In anderen Foren habe ich gelesen, daß dies aufgrund einer PHP-Spezifikation immer nach 990 Zeichen geschieht, aber keine Lösung gefunden.

Da es sich um keinen direkt zusammenhängenden Text handelt, kann man imho auch keine Texttrennung nach 990 Zeichen vornehmen... aka.

Text="abcdef!ghi" wird nicht durch Text="abcdef"+"ghi" gelöst...
(nur rein hypothetisch, bin kein PHP-Programmierer".

Gibts einen Trick, die 990-Zeichen-Grenze zu "knacken" bzw. das ! auszublenden, wegzulassen?

Danke (y)

Sephiroth
2008-04-02, 22:11:44
Ich höre zum ersten Mal davon, fand aber die folgende Bug Reports bei PHP. Leider steht da nicht drinn, wie man das umgehen kann.

Bug #13044 unexpected characters in mail (http://bugs.php.net/bug.php?id=13044)
Bug #31496 body output of mail() adds eroneous characters breaking output (http://bugs.php.net/bug.php?id=31496)


Welche PHP-Version habt ihr denn im Einsatz? Bei #13044 wird das auch noch bei der aktuellen 5.2.5 berichtet, von daher wird die Version wohl doch keine Rolle spielen.

p.s.
was ist mit wordwrap (http://de.php.net/manual/de/function.wordwrap.php)?

Lyka
2008-04-02, 22:17:02
ja, wir haben vor kurzem auf 5.2.5 ge-upgraded...

Danke für die Links :)

Sephiroth
2008-04-02, 22:32:25
Ich nochmal: offenbar liegt das an sendmail bzw. dem SMTP Protokoll selbst.

http://www.unix.com/unix-advanced-expert-users/11871-mail-attatchment-line-length.html#post42840
The L= equate is used to limit the length of text lines in teh body of a mail message.
If this equate is omitted and if they delivery agent has the obsolete F=L flag set (see 30.8.29), sendmail defaults to SMTPLINELIM (990) as defined in conf.h (see 18.8.43).
If the F=L is clear (as it is in modern configuration files), sendmail defaults to 0.
The F=L is honored for compatibility with older versions of sendmial that lack this L= equate.
The maximum line length for SMTP mail is 990 characters.



Und hier der Auszug aus der RFC 28822 (Internet Message Format) Abschnitt 2.1.1 (http://tools.ietf.org/html/rfc2822#section-2.1.1)
There are two limits that this standard places on the number of
characters in a line. Each line of characters MUST be no more than
998 characters, and SHOULD be no more than 78 characters, excluding
the CRLF.

The 998 character limit is due to limitations in many implementations
which send, receive, or store Internet Message Format messages that
simply cannot handle more than 998 characters on a line. Receiving
implementations would do well to handle an arbitrarily large number
of characters in a line for robustness sake. However, there are so
many implementations which (in compliance with the transport
requirements of [RFC2821 (http://tools.ietf.org/html/rfc2821)]) do not accept messages containing more
than 1000 character including the CR and LF per line, it is important
for implementations not to create such messages.

The more conservative 78 character recommendation is to accommodate
the many implementations of user interfaces that display these
messages which may truncate, or disastrously wrap, the display of
more than 78 characters per line, in spite of the fact that such
implementations are non-conformant to the intent of this
specification (and that of [RFC2821 (http://tools.ietf.org/html/rfc2821)] if they actually cause
information to be lost). Again, even though this limitation is put on
messages, it is encumbant upon implementations which display messages


Wordwrap sollte dann helfen

$message = wordwrap($message, 990, "\n", 1);