From:             aflem26 at hotmail dot com
Operating system: RHEL 3.0
PHP version:      4.3.9
PHP Bug Type:     Mail related
Bug description:  mail() adds headers and encodes the body

Description:
------------
system: vanilla rhel 3.0
original php version: 4.3.2
manually compiled and installed 4.3.9, but the bug persists

I have noticed that simple mail() calls result in php adding erroneous
headers in addition to and in conflict with those that I supply.  In
particular, the erroneous headers are:
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: BASE64


and php encoding the body into base 64, which shouldn't happen:
"body" gets encoded as Ym9keQ==




*please*, if this is to be expected, point me to some documentation, or
some explanation.  All my web based mail tools are broken due to the
additional header, and mail I send through them comes out all garbled,
because the mail script encodes the message, and then It gets encoded
*again*. please. 


Thanks so much.



my config line is as follows (long!): ./configure --host=i686-pc-linux-gnu
--build=i686-pc-linux-gnu --target=i386-redhat-linux --program-prefix=
--prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin
--sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include
--libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var
--sharedstatedir=/usr/com --mandir=/usr/share/man
--infodir=/usr/share/info --cache-file=../config.cache
--with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d
--enable-force-cgi-redirect --disable-debug --enable-pic --disable-rpath
--enable-inline-optimization --with-bz2 --with-db4=/usr --with-curl
--with-dom=/usr --with-exec-dir=/usr/bin --with-freetype-dir=/usr
--with-png-dir=/usr --with-gd --enable-gd-native-ttf --with-ttf
--with-gettext --with-ncurses --with-gmp --with-iconv --with-jpeg-dir=/usr
--with-openssl --with-png --with-pspell --with-regex=system --with-xml
--with-expat-dir=/usr --with-zlib --with-layout=GNU --enable-bcmath
--enable-exif --enable-ftp --enable-magic-quotes --enable-safe-mode
--enable-sockets --enable-sysvsem --enable-sysvshm --enable-discard-path
--enable-track-vars --enable-trans-sid --enable-yp --enable-wddx
--enable-mbstring --enable-mbstr-enc-trans --enable-mbregex --without-oci8
--with-pear=/usr/share/pear  --with-kerberos=/usr/kerberos
--with-ldap=shared --with-mysql=shared,/usr --with-pgsql=shared
--with-unixODBC=shared --enable-memory-limit --enable-bcmath
--enable-shmop --enable-versioning --enable-calendar --enable-dbx
--enable-dio --enable-mcal --with-apxs2filter=/usr/sbin/apxs

Reproduce code:
---------------
$more test.php
<?
  $header = "Content-Type: text/plain; charset=us-ascii";
  mail('[EMAIL PROTECTED]', 'subject', 'body', $header);
?>


Expected result:
----------------
Here's What I would Expect:
$php -d sendmail_path=/bin/cat test.php
To: [EMAIL PROTECTED]
Subject: subject
Content-Type: text/plain; charset=us-ascii

body



Actual result:
--------------
Here's what I get.  Please note the erroneous and conflicting Content-Type
header, and the un-invited content-transfer encoding that has been applied:


$php -d sendmail_path=/bin/cat test.php
To: [EMAIL PROTECTED]
Subject: subject
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: BASE64

Ym9keQ==



Here's the same thing, piped through xdd:

$php -d sendmail_path=/bin/cat test.php | xxd
0000000: 546f 3a20 6a6f 6540 7465 7374 2e63 6f6d  To: [EMAIL PROTECTED]
0000010: 0a53 7562 6a65 6374 3a20 7375 626a 6563  .Subject: subjec
0000020: 740a 436f 6e74 656e 742d 5479 7065 3a20  t.Content-Type:
0000030: 7465 7874 2f70 6c61 696e 3b20 6368 6172  text/plain; char
0000040: 7365 743d 7573 2d61 7363 6969 0a4d 696d  set=us-ascii.Mim
0000050: 652d 5665 7273 696f 6e3a 2031 2e30 0a43  e-Version: 1.0.C
0000060: 6f6e 7465 6e74 2d54 7970 653a 2074 6578  ontent-Type: tex
0000070: 742f 706c 6169 6e3b 2063 6861 7273 6574  t/plain; charset
0000080: 3d55 5446 2d38 0a43 6f6e 7465 6e74 2d54  =UTF-8.Content-T
0000090: 7261 6e73 6665 722d 456e 636f 6469 6e67  ransfer-Encoding
00000a0: 3a20 4241 5345 3634 0a0a 596d 396b 6551  : BASE64..Ym9keQ
00000b0: 3d3d 0a                                  ==.
$


-- 
Edit bug report at http://bugs.php.net/?id=30766&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=30766&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=30766&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=30766&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=30766&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=30766&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=30766&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=30766&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=30766&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=30766&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=30766&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=30766&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=30766&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=30766&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=30766&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=30766&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=30766&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=30766&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=30766&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=30766&r=mysqlcfg

Reply via email to