Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Php Generated Emails and Bare LFs SMTP Errors

Posted on 2003-12-02
2
Medium Priority
?
352 Views
Last Modified: 2012-06-22
Hi Everyone,

I am not a Php developer, however some of my clients PHP based scripts to generate emails get refused by various smtp relays, responding with links to http://cr.yp.to/docs/smtplf.html.

I understand the problem, but my question in short, is What is the best way to fix this issue?

Does the latest version of PHP fix this issue?  We are running a slightly older version.  Whilst some clients can probably edit their scripts directly, others may be using scripts like phpbb, which they cannot address.

Thanks.
0
Comment
Question by:Jimby_Aus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
petoskey-001 earned 2000 total points
ID: 9876526
The issue is that SMTP requires that lines end with Carriage Return then LineFeed.  This is ascii - 13 followed by ascii 10.  Unix/Linux uses only the line feed.  

When the script is creating the message it has only the line feed in it.  You can use the following process before your mail command to fix it.

Old command used to look like this...

   mail( $EmailToAddress, $EmailSubject, $EmailMessage, $EmailHeaders );

Modify the lines to look like this...

//    mail( $EmailToAddress, $EmailSubject, $EmailMessage, $EmailHeaders );

    $newMessage = ereg_replace("\n","\r\n", $EmailMessage);
    $newMessage = ereg_replace("\r\r\n", "\r\n", $newMessage);

    $newHeaders = ereg_replace("\n","\r\n", $EmailHeaders);
    $newHeaders = ereg_replace("\r\r\n", "\r\n", $newHeaders);

    mail( $EmailToAddress, $EmailSubject, $newMessage, $newHeaders );

This assumes they are using the built-in PHP command to send mail.  If their app uses direct telnet to the SMTP server then things won't be this easy.  You should be able to search the PHP files for the "mail(" line to figure out where to perform this replacement.  

More popular scripts like phpBB should not have this problem.

0
 
LVL 1

Author Comment

by:Jimby_Aus
ID: 9902030
Thanks, Ill test this out, then finalise the thread.
Jimby.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question