email system - only one real problem left

D

Dan

Dear All,

I am writing an intranet email suite for the practice, it needs to do
the following...

1. Suck in email from POP3 account
- Dead easy

2. Shove email into our mySQL database
- Should be pretty easy - i've just got to work out a couple of
things and it'll be working perfectly

3. Show user the contents of their inbox
- Dead easy

4. Take the email and separate any attachments on it, and stick them in
the folder on the server for download.
- This seams to be next to impossible! I have looked at
Email::Store, Email::MIME etc but I can't figure out how this can be
achieved using them. Is there a simple way to take a scalar containing
an full email and chop it up into its constituent parts? This seams
like such a simple task - but it's baffling me. Can you give me any
advise?
- I'm coming from a position of not being a computer scientist -
I tried to learn UUencode etc to try to do it manually, but it gave me
a really bad headache. I have a stack of over a hundred pages CPAN
module descriptions covering my desk like a fresh snow fall - please
give me some pointers.

5. Leave the email (inc attachments) on the server for future
reference.

Am developing on OS-X 10.4


Please help me.

Thank you,



Dan

Please.
 
B

Bart Van der Donck

Dan said:
[...]
4. Take the email and separate any attachments on it, and stick them in
the folder on the server for download.
- This seams to be next to impossible! I have looked at
Email::Store, Email::MIME etc but I can't figure out how this can be
achieved using them. Is there a simple way to take a scalar containing
an full email and chop it up into its constituent parts?
[...]

#!/usr/bin/perl

# attachments and mail body are extracted and go into
/path/to/directory/
# http://search.cpan.org/~eryq/MIME-tools-5.411a/lib/MIME/Parser.pm

use strict;
use warnings;
use MIME::parser;

my $mail = <<'EMAIL'
Return-Path: -
Delivered-To: -
X-Envelope-To:-
Received: -
Received: -
From: -
To: -
Subject: -
Date:-
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_NextPart_000_0031_01C62E4C.5FD821F0"

This is a multi-part message in MIME format.

------=_NextPart_000_0031_01C62E4C.5FD821F0
Content-Type: text/plain;
format=flowed;
charset="iso-8859-1";
reply-type=original
Content-Transfer-Encoding: 7bit

email body
------=_NextPart_000_0031_01C62E4C.5FD821F0
Content-Type: text/plain;
format=flowed;
name="one.txt";
reply-type=original
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="one.txt"

This is attachment with name one.txt
------=_NextPart_000_0031_01C62E4C.5FD821F0
Content-Type: image/gif;
name="two.gif"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="two.gif"

This is attachment with name two.gif
------=_NextPart_000_0031_01C62E4C.5FD821F0--
EMAIL
;

my $parser = new MIME::parser;
$parser->output_dir('/path/to/directory/');
my $entity = $parser->parse_data(\$mail);
 
D

Dan

thank you so much for such a complete answer - that's brilliant - i'll
try it when i'm back at my desk on monday.

thanks so much for your work!

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top