Jump to content

Pear Email script showing base64 instead of attachment


cs.punk

Recommended Posts

Hey guys... After battling with php's mail function I decided to try use the Pear Mail extension.

 

I manually downloaded the Mail/Mail_Mime extensions and extracted them into a folder on my host. My host doesn't support pear as im on a shared hosting account and so forth...

 

I've included a simple text file as an attachment but it's showing up as raw base64 on the email. Any ideas as to whats going on?

 

Anyway heres the script:

<?php
require_once "pear/Mail-1.2.0/Mail.php";
require_once "pear/Mail_Mime-1.8.5/Mail/mime.php";

$mail = Mail::factory("mail");

$message = new Mail_mime();
$message->setTXTBody("This is a test!");
$message->addAttachment("circle.txt"); 
$body = $message->get();

$headers = array("From"=>"me@example.com", "Subject"=>"Test Mail");
$mail->send("aoeu@gmail.com", $headers, $body);

 

This is the actual output in gmail:

--=_d4f892aa77bb2f7f126290d6354a013c

Content-Transfer-Encoding: quoted-printable

Content-Type: text/plain; charset="ISO-8859-1"

 

This is a test!

--=_d4f892aa77bb2f7f126290d6354a013c

Content-Transfer-Encoding: base64

Content-Type: application/octet-stream

Content-Disposition: attachment

 

CiAgICAgICAgICAgIC8vIENJUkNMRQogICAgICAgICAgICB1c2VyUHJpbWl0aXZlcyA9IG5ldyBW

ZXJ0ZXhQb3NpdGlvbkNvbG9yW3RyaUNvdW50XTsKCiAgICAgICAgICAgIGZvciAoaW50IGkgPSAw

OyBpIDwgdHJpQ291bnQgLSAxOyBpKyspCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGRv

dWJsZSBhbmdsZSA9IChpIC8gKHRyaUNvdW50IC0gMS4wRikpICogMiAqIE1hdGguUEk7CiAgICAg

ICAgICAgICAgICB1c2VyUHJpbWl0aXZlczJbaV0gPSBuZXcgVmVydGV4UG9zaXRpb25Db2xvcigp

OwogICAgICAgICAgICAgICAgZG91YmxlIHggPSBjZW50cmUuWCArIE1hdGguQ29zKGFuZ2xlKSAq

IHJhZGl1czsKICAgICAgICAgICAgICAgIGRvdWJsZSB5ID0gY2VudHJlLlkgKyBNYXRoLlNpbihh

bmdsZSkgKiByYWRpdXM7CgogICAgICAgICAgICAgICAgdXNlclByaW1pdGl2ZXNbaV0uUG9zaXRp

b24gPSBuZXcgVmVjdG9yMygoZmxvYXQpeCwgKGZsb2F0KXksIDApOwogICAgICAgICAgICAgICAg

dXNlclByaW1pdGl2ZXNbaV0uQ29sb3IgPSBDb2xvci5QdXJwbGU7CiAgICAgICAgICAgIH0KICAg

ICAgICAgICAgdXNlclByaW1pdGl2ZXNbdHJpQ291bnQgLSAxXSA9IHVzZXJQcmltaXRpdmVzMlsw

XTs=

--=_d4f892aa77bb2f7f126290d6354a013c--

 

And heres the 'original - raw email' :

                                                                                                                                                                                                                                                               
Delivered-To: oaeu@gmail.com
Received: by 10.152.127.232 with SMTP id nj8csp106163lab;
        Wed, 27 Jun 2012 12:07:38 -0700 (PDT)
Received: by 10.204.132.87 with SMTP id a23mr7469021bkt.134.1340824058608;
        Wed, 27 Jun 2012 12:07:38 -0700 (PDT)
Return-Path: <me@example.com>
Received: from moutng.kundenserver.de (moutng.kundenserver.de. [212.227.126.171])
        by mx.google.com with ESMTP id iu12si17714822bkc.92.2012.06.27.12.07.38;
        Wed, 27 Jun 2012 12:07:38 -0700 (PDT)
Received-SPF: neutral (google.com: 212.227.126.171 is neither permitted nor denied by best guess record for domain of me@example.com) client-ip=212.227.126.171;
Authentication-Results: mx.google.com; spf=neutral (google.com: 212.227.126.171 is neither permitted nor denied by best guess record for domain of me@example.com) smtp.mail=me@example.com
Received: from icpu968.kundenserver.de (infong1008.kundenserver.de [212.227.17.205])
by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis)
id 0MOELI-1SpRlO0gh2-005VFI; Wed, 27 Jun 2012 21:07:38 +0200
Received: from 188.29.137.212 (IP may be forged by CGI script)
    by icpu968.kundenserver.de with HTTP
    id 49mGfE-1RwEXn0QtZ-00yy68; Wed, 27 Jun 2012 21:07:38 +0200
X-Sender-Info: <380737050@icpu968.kundenserver.de>
Date: Wed, 27 Jun 2012 21:07:38 +0200
Message-Id: <49mGfE-1RwEXn0QtZ-00yy68@icpu968.kundenserver.de>
Precedence: bulk
To: aoeu@gmail.com
Subject: Test Mail
From: me@example.com
X-Provags-ID: V02:K0:XkW5H0+gB04F8ve/l0PJ4pVPIsl+BCKqgHQuyM6f2gT
SZYp6SqOt6uKoiZbpnkg/M3dDNk2ew8RFYTEftVdeS7zkpcMzt
4Jw15uh42lSdCY/spjGtWLwrICvCdIPHdJy8kvbyH32tS+M+L+
ivhozQkMPrgDEhwYCtutaxKXInNadwkYQ1OBQr+aKC5Yeo9WoH
Q2xG3eHqTZ1zt/v0kTzte3CWjTrmUJLRzoYg/Y1XiJtc2GvpCr
lmqrBwUf62w02Yqm8bQv+ZDSpNLE+yKtLPAbYv1S8lzzpE+cFj
SQWQHfVwkJgtHX/rfefSfzVHd+kh+kTnkJSGKGDx+Y+ZPTDzzV
yqL3L2M4f/mgeZEOZdICk0tTxaEJDVooCvmlHvfaEwQe1qHauA
U3fVbzzRntoighqj9PK4W371JazLYyQyTyW4gPmI43B7C3hpFn
EXV9p

--=_d4f892aa77bb2f7f126290d6354a013c
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="ISO-8859-1"

This is a test!
--=_d4f892aa77bb2f7f126290d6354a013c
Content-Transfer-Encoding: base64
Content-Type: application/octet-stream
Content-Disposition: attachment

CiAgICAgICAgICAgIC8vIENJUkNMRQogICAgICAgICAgICB1c2VyUHJpbWl0aXZlcyA9IG5ldyBW
ZXJ0ZXhQb3NpdGlvbkNvbG9yW3RyaUNvdW50XTsKCiAgICAgICAgICAgIGZvciAoaW50IGkgPSAw
OyBpIDwgdHJpQ291bnQgLSAxOyBpKyspCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGRv
dWJsZSBhbmdsZSA9IChpIC8gKHRyaUNvdW50IC0gMS4wRikpICogMiAqIE1hdGguUEk7CiAgICAg
ICAgICAgICAgICB1c2VyUHJpbWl0aXZlczJbaV0gPSBuZXcgVmVydGV4UG9zaXRpb25Db2xvcigp
OwogICAgICAgICAgICAgICAgZG91YmxlIHggPSBjZW50cmUuWCArIE1hdGguQ29zKGFuZ2xlKSAq
IHJhZGl1czsKICAgICAgICAgICAgICAgIGRvdWJsZSB5ID0gY2VudHJlLlkgKyBNYXRoLlNpbihh
bmdsZSkgKiByYWRpdXM7CgogICAgICAgICAgICAgICAgdXNlclByaW1pdGl2ZXNbaV0uUG9zaXRp
b24gPSBuZXcgVmVjdG9yMygoZmxvYXQpeCwgKGZsb2F0KXksIDApOwogICAgICAgICAgICAgICAg
dXNlclByaW1pdGl2ZXNbaV0uQ29sb3IgPSBDb2xvci5QdXJwbGU7CiAgICAgICAgICAgIH0KICAg
ICAgICAgICAgdXNlclByaW1pdGl2ZXNbdHJpQ291bnQgLSAxXSA9IHVzZXJQcmltaXRpdmVzMlsw
XTs=
--=_d4f892aa77bb2f7f126290d6354a013c--

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.