PHP Classes

Email to DB not working properly

Recommend this page to a friend!

      PHP Email To DB  >  All threads  >  Email to DB not working properly  >  (Un) Subscribe thread alerts  
Subject:Email to DB not working properly
Summary:Email To DB fails if a plain text mail also has a txt attachment
Messages:5
Author:Rainer Hapatzky
Date:2008-10-29 08:43:39
Update:2010-09-04 08:24:52
 

  1. Email to DB not working properly   Reply   Report abuse  
Picture of Rainer Hapatzky Rainer Hapatzky - 2008-10-29 08:43:41
I found your emailtodb class - and in principle it's exactly what I need.

I need to extract from the mail is besides senderinformation:
- mail subject
- mail text
- mail attachments - if any.

in principle exactly what your class is promising to do.

Unfortunatelly - if i run a simple test - it produces the wrong result.

My testcase is very simple:

I create a mail using Thunderbird with:

Mail subject the word :Testsubject
Mail text only the word: TEST
one mail attachment named: test.txt with three lines in it: Line1 xxx, Line2 yyy, Line3 zzz

simple.

but when I sent it and the mail is processed by your class the following happens:

emailtodb_email Subject is: Testsubject - thats ok
emailtodb_email Message is: xxx yyy zzz - which is wrong - should be in a file on disk and instead of xxx yyy zzz i would expect to see TEST here.
The mail text TEST is missing completely.

If I replace the text.txt attachment by a powerpoint file, all seems to be ok except I get no info about the mimetype.

I would appreciate it very much if you could help me.

Thanks in advance for your help

With kind regards,
Rainer Hapatzky

  2. Re: Email to DB not working properly   Reply   Report abuse  
Picture of Sebastien Rivest Sebastien Rivest - 2009-08-04 01:45:04 - In reply to message 1 from Rainer Hapatzky
hi, have you found any answer of that problem, cause I have the same here...

tks

Seby

  3. Re: Email to DB not working properly   Reply   Report abuse  
Picture of Par Par - 2009-09-04 10:39:54 - In reply to message 1 from Rainer Hapatzky
Same for me

I get the none-text attachments with this code

$edb = new EMAIL_TO_DB();
$edb->connect('CONNECTS TO MAILBOXES');
$int_totalEmails = $edb->num_message();

for ($i=1; $i<=$int_totalEmails; $i++) {
//Resets partsarray
$edb->partsarray = NULL;
$bit_plainFound = 0;
$edb->msgid = $i; //Sets pointer to a message
$email = $edb->email_get(); //Gets message from server

foreach($edb->partsarray as $partText){
$part = null;
$part = $partText['text'];


if($partText["attachment"]) {
$bit_attached = 1;
#Save files(attachments) on local disc
foreach(array($partText["attachment"]) as $attach){
$attach["filename"] = $edb->mimie_text_decode($attach["filename"]);
$attach["filename"] = preg_replace('/[^a-z0-9_\-\.]/i', '_', $attach["filename"]);

$edb->save_files($email['FROM_EMAIL'] . "_" . $attach["filename"], $attach["string"]);
}
}
}
}
}

Donīt forget to set var $file_path in EMAIL_TO_DB class file


But I canīt get the text attachments!

  4. Re: Email to DB not working properly   Reply   Report abuse  
Picture of Lil Peck Lil Peck - 2010-09-04 08:24:52 - In reply to message 3 from Par
OK, I see that the script is set up to process only image attachments. If you take a look at the code, you'll see a Switch and only image attachments are provided for.

  5. Re: Email to DB not working properly   Reply   Report abuse  
Picture of joey martin joey martin - 2014-09-26 03:17:20 - In reply to message 4 from Lil Peck
Did you get this working?