Re: email in html format?

From: Date: Thu, 20 Jul 2000 14:21:30 +0000
Subject: Re: email in html format?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-7420@lists.php.net to get a copy of this message
Tremayne Smith wrote: > > An associate and myself have used the script provided by Mr. Heyes to > successfully send an html formatted email message. However; when a recipient > only has the ability to read the text version, we have received complaints that > the message is being displayed as a single string with no line breaks. Some e-mail clients insert line-breaks in incoming e-mail, others do not. To be safe, it's a good idea to break lines in plain-text e-mails before sending it. A little script which does this (I'm not saying it's the best, but it works for me): // break lines that are too long and return the result // 'str' is the text to be broken up // 'length' is the max. number of characters per line // returns the 'str' broken into lines function breakLines($str, $length) { // make sure we deal only with newlines $res = ""; $str = ereg_replace("\r\n", "\n", $str); $lines = explode("\n", $str); $lsep = ""; for (reset($lines); list(, $line) = each($lines); $lsep = "\n") { $line = chop($line); // trailing white space killed if (strlen($line) > $length) { // search backwards in line for first char before 'length' which // is a space $words = explode(" ", $line); $len = 0; $wsep = ""; $printnl = true; // need to print 'lsep' once for (reset($words); list(, $word) = each($words); $wsep = " ") { $len += strlen($word . $wsep); if ($len > $length) { if (strlen($word) > $length) { $res .= "\n" . chunk_split($word, $length, "\n"); $len = strlen($res) - strrchr($res, "\n"); } else { $res .= "\n$word"; $len = strlen($word); } } else $res .= ($printnl ? $lsep : "") . $wsep . $word; $printnl = false; } } else $res .= $lsep . $line; } return $res; } > If I > send the text only version to myself using the mail function, I receive a > properly formatted message. We have not received anymore info from the > complainers as to which email client they were using. Also if I attempt to view > a message sent using Mr. Heyes's script by typing mail at my Unix terminal, I > get gibberish. > > I am a newbie to the protocol and encoding standards of email, so I have no idea > where this problem could be originating. So any advice that anyone is willing > to share will be greatly appreciated. Thanx in advance. > > Tre' > > Richard Heyes wrote: > > > > This appears to be exactly what I need. I appreciate your > > > help, take care. > > > > Out of courtesy you might want to check though whether your subscribers wish > > to recieve HTML mail. Personally I hate the stuff. :) > > > > Take care. > > > > -- > > Richard Heyes > > http://www.heyes-computing.net/scripts/ > > Plain text email only please! > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#7420) next »