core/MailHelper

JaTu

Joined: 2004-08-23
Posts: 6
Posted: Wed, 2006-02-22 15:42

There seems to be forced CR/LF in MailHelper.
$headers = "Content-Type: text/plain; charset=\"utf-8\"\r\n" . $headers;

Any ideas why is that? It seems to be causing trouble on Linux + Postfix/qmail. Sure RFC822 says CR/LF-pair, but in this case the result is CR/CR/LF which for known reasons does non't work.

Regards,
Jari Turkia

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2006-02-22 16:12

the smtp specification says that mail header fields must be delimited by \r\n

 
JaTu

Joined: 2004-08-23
Posts: 6
Posted: Thu, 2006-02-23 08:32
Quote:
the smtp specification says that mail header fields must be delimited by \r\n

Sure. But since I'm running Linux, all text is chr(10) delimited (\n). It is the task of the local MTA to take care of proper standards before transmitting anything on the wire. In this case this specific MTA very much dislikes chr(13)chr(10) pair in the incoming text and does Bad Things(tm) to the outgoing mail headers.

The assumptions in the code currently are:
1) user is running an operating system delimiting text lines with CR/LF
2) those who aren't 1), are running Mail Transfer Agent being capable of handling CR/LF delimited text properly
3) (unintentional) if you aren't 1) or 2), you are out of luck

The reason I'm discussing the problem here is because I'd like the developers to know about this potential problem. There are bunch of people who don't know how to fix this, so it might be a bright idea to try to compensate this somehow in the code.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2006-02-23 10:40

you're the first to report an issue with that code.

note that we offer 2 solutions in g2:
- mail via local MTA (sendmail, ..:)
- mail via socket / SMTP connection to a 3rd party SMTP server, as defined in site admin -> general

the later requires that we conform to the SMTP standard, i.e. use \r\n . that's platform independent of course.

the former might require, in some weird cases, that we use platform specific line delimiters.

please file a bug such that we can move this code to a place after the SMTP / mail() abstraction such that we can use platform depdent code for one case and SMTP specfic code for the other.

 
JaTu

Joined: 2004-08-23
Posts: 6
Posted: Thu, 2006-02-23 11:23

Ok. I'll look around for a place to submit a bug.

Totally off-topic whining of mine:
These new Gallery-pages are a bit unorganized for a non-regular visitor like me. Wouldn't it be great to have a short list in the support-pages saying:
- Read [FAQ], all the general questions are answered there.
- Search [forums], if anybody else has/had the same problem you are having. Find possible solution too!
- Search [bug database], if anybody else already submitted a report about it.
- Submit a new [bug report], if you insist on somebody writing new code to fix the problem.
Off-topic whining ends here.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sun, 2006-02-26 17:03

valiant, how can we make that determination? we only know if we call mail() or use SMTP.. but we don't know what mail() will do. is it safe to assume giving platform line separators to mail() will work? mail() on windows will use SMTP, but since we're on windows we'll use \r\n anyway. can mail() on unix be configured to use SMTP instead of direct sendmail call? hm, php manual says SMTP and smtp_port php.ini settings are windows only, so maybe this assumption will be ok.

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Thu, 2006-06-15 05:58

I just fixed this in rev 13828.