fatkatie Posted January 16, 2018 Share Posted January 16, 2018 I finally got a godaddy client to pipe my mail into a local folder. The file names look like 1516137911.M489417P234988.p3plcpnl0896.prod.phx3.secureserver.net,S\=953331,W\=963315 (the file name(?) seem quite irregular - I don't recognize it) I can cat it and I'm convinced everything is there. I know I have to open these with some php class/function that understands the structure, so that I can pluck out what I want. But I don't have a clue how to even begin this. This is one of the 'get of the dime' post. A single example, a short one, would be much appreciated. Thank you. godaddy, php7 Quote Link to comment Share on other sites More sharing options...
ginerjm Posted January 16, 2018 Share Posted January 16, 2018 I don't know if all hosts do this but my host (DEFINITELY not godaddy) allows me to setup my mailbox to pipe automatically to a script that I provide. Then I can read the mails just as soon as they arrive and do what I want with them. However - I am not aware of any php function that makes the 'reading' easy. I just go thru them looking for the pieces I expect. And as for that 'filename' you have been given, are you sure that is the system filename, or some name assigned in the mailbox by the mail server? Quote Link to comment Share on other sites More sharing options...
fatkatie Posted January 17, 2018 Author Share Posted January 17, 2018 Here's an ls -al witheral@p3plcpnl0896 [~/mail/new]$ ls -al total 944 drwxr-x--x 2 witheral witheral 4096 Jan 16 14:25 ./ drwxr-x--x 10 witheral witheral 4096 Jan 16 14:25 ../ -rw-r----- 1 witheral witheral 2584 Jan 16 13:54 1516136052.M746104P19939.p3plcpnl0896.prod.phx3.secureserver.net,S\=2584,W\=2624 -rw-r----- 1 witheral witheral 952631 Jan 16 14:25 1516137911.M489417P16988.p3plcpnl0896.prod.phx3.secureserver.net,S\=952631,W\=965015 witheral@p3plcpnl0896 [~/mail/new]$ The "LOOK" like files and the cat. But who knows. I was hoping there was a reader class I could pick up. I haven't found one yet ... or maybe I have and don't realize it. I've never been here before. The files are deposited here by the godaddy client. It was setup thru the forwarding panel, under advanced. You ID your account and all the mail is dropped in the mail folder. Quote Link to comment Share on other sites More sharing options...
fatkatie Posted January 17, 2018 Author Share Posted January 17, 2018 More. The last mail file is large because it contains a photo attachment. Quote Link to comment Share on other sites More sharing options...
fatkatie Posted January 17, 2018 Author Share Posted January 17, 2018 Ah HA! The key was to use 'parse' in the search. "Read" just didn't do it. This isn't a done deal yet, but there seem to be a load of "raw" mail file parsers. I'll let you tomorrow. Thanks for the reply. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted January 17, 2018 Share Posted January 17, 2018 If you're happy, we're happy. Most of what you have posted makes no sense to me and perhaps the rest of us. For ex.: What does this line mean: "Here's an ls -al" ? And: 'The "LOOK" like files and the cat. But who knows.' What is that line saying? Quote Link to comment Share on other sites More sharing options...
requinix Posted January 17, 2018 Share Posted January 17, 2018 The file format could be the raw email - email headers and body, just like with HTTP. You have to worry about multipart messages, where text and HTML and sometimes inline images are all contained together, but otherwise it works much like understanding HTTP responses. The file names look like 1516137911.M489417P234988.p3plcpnl0896.prod.phx3.secureserver.net,S\=953331,W\=963315 (the file name(?) seem quite irregular - I don't recognize it) Look in the file contents for bits of that filename. It is likely derived from the unique message ID assigned to emails sent by servers, such as Message-ID: Not sure what the S and W would be, off the top of my head. For ex.: What does this line mean: "Here's an ls -al" ?ls shows files in a directory. It's the Linux equivalent to Windows' dir command. - By convention, filenames in Linux that start with a period are hidden from normal browsing. That's why stuff like Apache's .htaccess is named with that leading period. ls -a means to show all files, including "hidden" files. - Normally ls just outputs the names of the files without any details about them. ls -l will show ownership and size (along with some other stuff) as well. And: 'The "LOOK" like files and the cat. But who knows.' What is that line saying?I think it means "they look like plain files with cat"; cat is a program that dumps out the contents of files. Quote Link to comment Share on other sites More sharing options...
fatkatie Posted January 17, 2018 Author Share Posted January 17, 2018 Too cryptic. Sorry. I hate when others do it. Thanks to admin for cleaning it up. The files, and indeed they were, are a mess of encoded plain text.Godaddy supplies a parser that you can install. This is what I am now using.http://pear.php.net/manual/en/package.mail.mail-mimedecode.mail-mimedecode.php Typical use. $fh = fopen($file, 'r'); $contents = fread($fh, filesize($file)); $decoder = new Mail_mimeDecode($contents); $params['decode_headers'] = true; $structure = $decoder->decode($params); The structure returned contains associative arrays that you can access. The params array is used to engage different parsers. Thanks all. Quote Link to comment Share on other sites More sharing options...
fatkatie Posted January 19, 2018 Author Share Posted January 19, 2018 op - if this is just too pretentious, delete it. But I thought this might be interesting for someone with a first date with mail files.The raw mail file is simply opened and read with php's fopen and fread. The contents are passed into the constructor. To actually read and save the image data itself, you have to add the 'decode_bodies' param. A print_r copy of the header structure returned by $decoder = new Mail_mimeDecode($rew_mail_file_contents); $params['decode_headers'] = true; $structure = $decoder->decode($params); print_r($structure , true); is below. After working with it for awhile, I was able to extract the image file and includeit in the site. It's great to have things work.. finally. [headers] => Array ( [return-path] => Array ( [0] => <wipatah@yahoo.com> [1] => <wipatah@yahoo.com> ) [delivered-to] => wipatah@p3plcpnl0896.prod.phx3.secureserver.net [received] => Array ( [0] => from p3plcpnl0896.prod.phx3.secureserver.net by p3plcpnl0896.prod.phx3.secureserver.net (Dovecot) with LMTP id FXY8GrdtXlpcQgAAgoAqXA for <wipatah@p3plcpnl0896.prod.phx3.secureserver.net>; Tue, 16 Jan 2018 14:25:11 -0700 [1] => from sonic301-22.consmr.mail.gq1.yahoo.com ([98.137.64.148]:38877) by p3plcpnl0896.prod.phx3.secureserver.net with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89) (envelope-from <wipatah@yahoo.com>) id 1ebYjF-0004un-MY for corkboard@yahoo.com; Tue, 16 Jan 2018 14:25:11 -0700 [2] => from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.gq1.yahoo.com with HTTP; Tue, 16 Jan 2018 21:24:28 +0000 ) [envelope-to] => corkboard@yahoo.com [delivery-date] => Tue, 16 Jan 2018 14:25:11 -0700 [dkim-signature] => v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1516137868; bh=06bgUjh9uX3v3rNBUAmFfNqAAjSl9jUbvfvGDXEIzcM=; h=Date:From:Reply-To:To:Subject:References:From:Subject; b=D2o/wsESjfuMyJsvBiUS8fpLKynZ8Wk9yg0GjJD4dczxKDoW4ASPWien9NWf0gW7nPfzY1PCOSGqxM9toGiyzgF/O3/aDuicyM3iZSyiJ3BkXbFQNgobvrcbfeb6x2rA3KzJ4w3k+O7uttOLy3/Atx83D3k7Qim1/VALDGVAIs5ruULZL7gj7IM49U8UtRS1b9S32FnFJG6W5h7Hi6zQI0sEW+HvaDWMtg1556BDBtRcXMKqqoC2s7FmbyPqONH3/Dg05CKMOHvZyIq1wyHLlEXxhKTNRwfPxNu9+kDJyOlWJCjdH4jlNRmX9r2N+w63m4SNVaJlcwfu3AYToKrSLA== [x-ymail-osg] => T.VrZWUVM1n4AT4j8Ca8wcfVdLMixy8SpNQEld7NIa2hqY7UZ8iSkS3Qx8.i39A ozjgbfabcfSORG2EitbSWd5kLra6hQtj3digxH6V5CUXbmMOybz7b17C3eXQCvjASMd9JnBtU9GA jgpGWO3tGPHhGzolYbwbfPz9yV34QgcpOuUsLOYZRYk1onwVTILsxkh0JxOg6L3si9k_G8HpxyM. IlV4ipdKI1f39ZYQqrUNsHsONLgNy_0b1wOwnoKE1hgST8JVTzV2kcOTRPZnq06BMGvzkdBuLGaB P19ZzWm9_IYi0Kru.o4rUYOCYXFJwGBuBM_0h8aYNQPyJGvGq5biaQUcaYJVBlZBCSGvOkDWFyjA .3BP6Llol8Kl5WI5YNmcR060f.z.1VNNH0nCGfOHg8kSJNhBFjRkRIsFhLTV0gu79KtjHyozUcsa CYP.AVqJs56eN9pj09LIs.0BZjAhT3rQhpy9LLdmwc3wcn8PIC2BCrDFaJSlaw0z8RAygbouhGvJ xZp6HPVaxt0kLUBSHt0sa [date] => Tue, 16 Jan 2018 21:24:25 +0000 (UTC) [from] => Old York <wipatah@yahoo.com> [reply-to] => Old York <wipatah@yahoo.com> [to] => <corkboard@yahoo.com> [message-id] => <1734813772.3210736.1516137866172@mail.yahoo.com> [subject] => attachment test - one pic [mime-version] => 1.0 [content-type] => multipart/mixed; boundary="----=_Part_3210735_791904605.1516137866172" [references] => <1734813772.3210736.1516137866172.ref@mail.yahoo.com> [x-mailer] => WebService/1.1.11185 YahooMailBasic Mozilla/5.0 (Windows NT 6.1; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0 [content-length] => 950049 ) [ctype_primary] => multipart [ctype_secondary] => mixed [ctype_parameters] => Array ( [boundary] => ----=_Part_3210735_791904605.1516137866172 ) [parts] => Array ( [0] => stdClass Object ( [headers] => Array ( [content-type] => text/plain; charset=UTF-8 [content-transfer-encoding] => 7bit ) [ctype_primary] => text [ctype_secondary] => plain [ctype_parameters] => Array ( [charset] => UTF-8 ) ) [1] => stdClass Object ( [headers] => Array ( [content-type] => image/jpeg [content-transfer-encoding] => base64 [content-disposition] => attachment; filename="100_4562.JPG" [content-id] => <ULaxbEuGA97UmgQ5Nmdw> ) [ctype_primary] => image [ctype_secondary] => jpeg [disposition] => attachment [d_parameters] => Array ( [filename] => 100_4562.JPG ) ) ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.