cs.punk Posted June 27, 2012 Share Posted June 27, 2012 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"=>"[email protected]", "Subject"=>"Test Mail"); $mail->send("[email protected]", $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: [email protected] 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: <[email protected]> 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 [email protected]) 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 [email protected]) [email protected] 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: <[email protected]> Date: Wed, 27 Jun 2012 21:07:38 +0200 Message-Id: <[email protected]> Precedence: bulk To: [email protected] Subject: Test Mail From: [email protected] 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 https://forums.phpfreaks.com/topic/264896-pear-email-script-showing-base64-instead-of-attachment/ Share on other sites More sharing options...
btherl Posted June 28, 2012 Share Posted June 28, 2012 I don't see any mime headers here. Try setting the headers according to this example: http://pear.php.net/manual/en/package.mail.mail-mime.example.php Link to comment https://forums.phpfreaks.com/topic/264896-pear-email-script-showing-base64-instead-of-attachment/#findComment-1357624 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.