?
Solved

CSV files stripped from email sent via PHP script

Posted on 2008-06-20
2
Medium Priority
?
663 Views
Last Modified: 2013-12-13
Our issue is as follows. Emails are sent to an SBS2003 server via a PHP script - the attachemtent is a simple CSV file. We can receive the file and are running Exchange 2007 however the recipient gets the following email both internally and via OWA. We also have the same problem when sending to another SBS2003 server. I have attached the PHP script.

Cheers Simon

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="R***H***123"
Message-Id: <20080620075732.BE7E117D0679@123631-ftp1.urban*****.com>
Date: Fri, 20 Jun 2008 02:57:32 -0500 (CDT)
X-Spam: [F=0.4826833394; B=0.500(0); CM=0.500; MH=0.500(2008062003); R=0.600(10852012539); S=0.383(2008052701); SS=0.500; SC=none]
X-MAIL-FROM: <apache@123631-ftp1.urban*****.com>
X-SOURCE-IP: [74.***.126.***]
X-AnalysisOut: [v=1.0 c=1 a=yTYxI62HnN/3kBiX9mLl5Q==:17 a=8gbDEKxhH1KCzB_z]
X-AnalysisOut: [nYEA:9 a=vwKfExwf_oOp2VpywQwpY2dDrvsA:4 a=I7_3IfUV4NgA:10 ]
X-AnalysisOut: [a=IH9376qGKM7Ep32upmUA:9 a=-kqo6GrQS2aUI4clCXNGC5XcyqUA:4 ]
X-AnalysisOut: [a=O58u2wXj750A:10 a=4a0V8oAklmkA:10]
Return-Path: apache@123631-ftp1.urban*****.com
X-OriginalArrivalTime: 20 Jun 2008 07:57:34.0300 (UTC) FILETIME=[4C6531C0:01C8D2AB]

Please see the latest csv file attached.

--R***H***123

Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Please see the latest csv file attached.
--R***H***123
Content-Type: text/csv; name="real.csv"
Content-Transfer-Encoding: base64
Content-disposition: attachment; file="real.csv"
T1JERVIgTlVNQkVSLCBEQVRFIE9GIE9SREVSLCBTVE9DSyBDT0RFLCBRVFksIERFTElWRVJZIEFE
RFJFU1MgTElORSAxLCBERUxJVkVSWSBBRERSRVNTIExJTkUgMiwgREVMSVZFUlkgQUREUkVTUyBM
SU5FIDMsIERFTElWRVJZIEFERFJFU1MgTElORSA0LCBERUxJVkVSWSBBRERSRVNTIExJTkUgNSwg
UE9TVENPREUsIFRFTEVQSE9ORSwgRU1BSUwgQUREUkVTUwpPcmRlciBObzogMTIxMzk0Mjk4NDk3
NDEsIDIwLzA2LzA4LCBSSDFGMDAwNCwgMSwgTmljaG9sYSBHcmVlbiwgQmVlY2h3b29kIE5vcnRo
ZmllbGQgTGFuZSwgSGlnaGJ1cnRvbiwgSHVkZGVyc2ZpZWxkLCBVbml0ZWQgS2luZ2RvbSwgSGQ4
IDBxdCwgUGhvbmU6IDAxNDg0IDYwNjM5NSwgbmljaG9sYS5ncmVlbkB2aXJnaW4ubmV0Cg==
--R***H***123--

<?php
$to = "richard@urban*****.**"; 
$file_name = "real.csv";
$subject = "R*** H*** Orders";
 
$bound_text = "R***lH***1234";
$bound = "--".$bound_text."\r\n";
$bound_last = "--".$bound_text."--\r\n";
 
$headers = 	"From: do_not_reply@r***lh***.co.uk\r\n";
$headers .= "MIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"$bound_text\"";
$message = "Please see the latest csv file attached.\r\n$bound";
$message .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n"
  	."Content-Transfer-Encoding: 7bit\r\n\r\n"
  	."Please see the latest csv file attached.\r\n"
  	.$bound;
$file = file_get_contents("/var/www/html/r***h***/" . $file_name);
$message .= "Content-Type: text/csv; name=\"$file_name\"\r\n"
  	."Content-Transfer-Encoding: base64\r\n"
  	."Content-disposition: attachment; file=\"$file_name\"\r\n\r\n"
  	.chunk_split(base64_encode($file))
  	.$bound_last;
 
mail($to, $subject, $message, $headers);	
?>

Open in new window

0
Comment
Question by:leehewson
[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
 

Author Comment

by:leehewson
ID: 21829422
Thanks Simon
0
 
LVL 48

Accepted Solution

by:
hernst42 earned 2000 total points
ID: 21829458
Problem is the encoding and headers migth not be done correctly. I recommend ussing a PHP-mail.class which has been testend and is known to work properly with attachments.
http://phpmailer.sf.net
http://swiftmailer.sf.net
Typical they are also easier to use
0

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
Suggested Courses

770 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