0
我正在使用pipe編程將電子郵件發送到腳本。使用此腳本,我可以成功將整個電子郵件保存爲我的服務器上的.txt文件。唯一要做的就是弄清楚如何保存電子郵件附件中的任何附件。 (此電子郵件地址只授予一個可信賴的來源,所以安全性不是問題)通過管道電子郵件保存電子郵件附件
,節省了整個郵件的.txt文件工作代碼:
$fd = fopen("php://stdin", "r");
$email = ""; // This will be the variable holding the data.
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
/* Saves the data into a file */
$fdw = fopen("/home/lmshost22/public_html/pipemail.txt", "w+");
fwrite($fdw, $email);
fclose($fdw);
誰能幫助我的代碼,僅僅提取物附件(將始終是一個.csv文件)並將其保存在我的服務器上?
下面是.txt文件示出了用於附件的代碼:
------=_NextPart_000_0133_01CE0E98.061E7400
Content-Type: application/vnd.ms-excel;
name="leads.csv"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="leads.csv"
ApplicationDetailId,DateCreated,VehicleInfoId,FirstName,MiddleName,LastNa=
me,Suffix,Street,City,State,ZipCode,Email,HomePhoneArea,HomePhonePrefix,H=
omePhoneSuffix,CellArea,CellPrefix,CellSuffix,WorkPhoneArea,WorkPhonePreF=
ix,WorkPhoneSuffix,AmountBorrow,IsVehiclePaidOff,IsVehicleSalvaged,OweAmo=
unt,TitleOwnership,IsInBankruptcy,IsInCreditCounseling,HearOfUs,VehicleIn=
foId,Year,Make,Model,Trim,Miles,Engine,DriveTrain,Transmission,Options,Bo=
ok,ClassCode,Door,FuelType,BodyStyle
4523,2/18/2013 2:56:33 PM,4524,James,,Pruitt,,7900 =
Carmelita,Atascadero,CA,93422,,702,=3D"353",=3D"9760",=3D"",=3D"",=3D"",=3D=
"",=3D"",=3D"",=3D"2500.0000",True,False,0.0000,No =
one,False,False,Google,4524,2001,=3D"Toyota",Tacoma =
Xtracab,PreRunner,200000,V6 3.4 =
Liter,2WD,Automatic,199443~199448~199471~199480~199508~4234190~,0.0000,1,=
0,Gas,Pickup
------=_NextPart_000_0133_01CE0E98.061E7400--
該消息確實是多部分/混合。 MIME-Version:1.0 Content-Type:multipart/mixed; \t boundary =「---- = _ NextPart_000_0133_01CE0E98.061E7400」 X-Mailer:Microsoft Outlook 14.0 – user1789437 2013-02-19 18:25:06