Skip to content


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

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
  • E-mail this story to a friend!
  • 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.

Posted in Tips of the Week. Tagged with , .

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.