Tip of the Week : Carriage Returns in PHP Plain Text Emails

by frank on April 3, 2008

Another quick tip for the archives. Carriage returns on lines in your view finishing with a php statement. Try sending these views as an email and somehow the resulting email does not look entirely correct. The carriage returns have not been passed through.

This is a quick, hackish, tip so I really didn’t get to the bottom of it. Either PHP or Zend mail or possibly savant 3 the templating engine has some error here.

e.g:


Hi  eprint($this->sUserName) ?>
Email sent by eprint($this->sSenderName) ?>

The carriage returns here will not be recognised in the plain text email you send, which I was sending using Zend mail. The above is an example of a plaintext template view I was using.

In order to fix this all I needed to ensure was that there is a character at the end of everyline before the carriage return. A space does the trick. As long as your line finished in an ordinary character everything works smoothly.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • Fark
  • Reddit
  • StumbleUpon

Profile:  Frank has been programming for the web using PHP, Javascript and numerous libraries and frameworks for the past 5 years. More articles.

Leave a Comment

Previous post:

Next post: