Jump to content

paul.mearing

Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

paul.mearing's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, Ive been trying for a while to find some code that will parse and save off email attachments to files into a folder. I have created a function that will parse the plain text section of the email (dont need the html part), but was wondering if someone could point me in the right direction for the attachments?? I have tried snippets of code on the php.net site but cant seem to get them working. This was one of the examples I tried and modified to read new mail: <?php $mbox = imap_open("{xchurch-svr01:143}INBOX", "test", "test") or die("Connection to server failed"); $emails = imap_search($mbox, 'UNSEEN'); if(!empty($emails)){ echo "emails found"; foreach($emails as $mid) { $struct = imap_fetchstructure($mbox, $mid); $parts = $struct->parts; $i = 0; if (!$parts) { /* Simple message, only 1 piece */ $attachment = array(); /* No attachments */ $content = imap_body($mbox, $mid); } else { /* Complicated message, multiple parts */ $endwhile = false; $stack = array(); /* Stack while parsing message */ $content = ""; /* Content of message */ $attachment = array(); /* Attachments */ while (!$endwhile) { if (!$parts[$i]) { if (count($stack) > 0) { $parts = $stack[count($stack)-1]["p"]; $i = $stack[count($stack)-1]["i"] + 1; array_pop($stack); } else { $endwhile = true; } } if (!$endwhile) { /* Create message part first (example '1.2.3') */ $partstring = ""; foreach ($stack as $s) { $partstring .= ($s["i"]+1) . "."; } $partstring .= ($i+1); if (strtoupper($parts[$i]->disposition) == "ATTACHMENT") { /* Attachment */ $attachment[] = array("filename" => $parts[$i]->parameters[0]->value, "filedata" => imap_fetchbody($mbox, $mid, $partstring)); } elseif (strtoupper($parts[$i]->subtype) == "PLAIN") { /* Message */ $content .= imap_fetchbody($mbox, $mid, $partstring); } } if ($parts[$i]->parts) { $stack[] = array("p" => $parts, "i" => $i); $parts = $parts[$i]->parts; $i = 0; } else { $i++; } } /* while */ } /* complicated message */ echo "Analyzed message $mid, result: <br />"; echo "Content: $content<br /><br />"; echo "Attachments:"; print_r ($attachment); } else { echo "no mail"; } ?> All i get with this is a http 500 error!
  2. [!--quoteo(post=372628:date=May 9 2006, 04:12 PM:name=obsidian)--][div class=\'quotetop\']QUOTE(obsidian @ May 9 2006, 04:12 PM) [snapback]372628[/snapback][/div][div class=\'quotemain\'][!--quotec--] you're close, but he's recommended using strftime() on the outside, not strtotime(). also, you could use date(): [code] $open_date1 = date("Y-m-d I:Mr", strtotime($open_date)); [/code] [/quote] When i try to use: [code]$open_date1 = strftime("Y-m-d I:Mr", strtotime($open_date));[/code] i get blanks results...when i try it with date(), i get the following error: Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in c:\inetpub\wwwroot\magic8\SevBoard\PHPSevboard\sev123brd.php on line 86
  3. [!--quoteo(post=372581:date=May 9 2006, 02:42 PM:name=rt-box)--][div class=\'quotetop\']QUOTE(rt-box @ May 9 2006, 02:42 PM) [snapback]372581[/snapback][/div][div class=\'quotemain\'][!--quotec--] $output = strftime("Y-m-d I:Mr", strtotime($date_from_db)); In versions prior to PHP 5, you'd also have to get rid of the microseconds in the time you get from the database, as it will generate an error in strtotime(). For further precision, read the documentation. hth [/quote] When i try what you should, I get all my results echo'ing out as "-1". This is my code: [code]$open_date1 = strtotime("Y-m-d I:Mr", strtotime($open_date));[/code] Got any ideas?
  4. Hi, I have outputs from a sql database which print out in this format: 2006-05-09 18:11:20.000 is there a simple way i can format it so it looks like this: 2006-05-09 6:20pm Any ideas? Thanks.
  5. Hi, I've seen on sites how you can have a normal input button which allows you to insert text into the box. I want to have a button that will insert a html tag where ever the cursor is in the text area. I.e. if i have just typed a URL, I would like to be able to highlight this and then click on the hyperlink button. this would insert the h ref tag and closed tag and the start and finsish so this becomes a link. Is this possible just using javascript / html, or would i need to find a rich text editor like what is used when you add a new topic / post?? Would appreciate your input, Cheers Paul.
×
×
  • 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.