View previous topic :: View next topic |
Author |
Message |
joel Guest
|
Posted: Mon Aug 16, 2004 8:07 pm Post subject: |
|
|
Okej, I think I know the problem is that the message is not attached. The message is rather in the same "file" as the headers and subject, thus its not parsed in the script.
Does this make any sense? |
|
Back to top |
|
 |
Peffis Site Admin
Joined: 09 Sep 2003 Posts: 324 Location: Sweden
|
Posted: Tue Aug 17, 2004 7:58 am Post subject: |
|
|
One way to know is to check in the directory that is created for the message (the directory where the image is stored) and see if there is any text message there. By looking at yours (this one for instance http://mobil.rosafluffmoln.nu/msgstore/18050_1092477194_email/) it doesn't look like there are any text messages there I'm afraid. So for these messages Peffisaur might not work I suppose. |
|
Back to top |
|
 |
joel Guest
|
Posted: Tue Aug 17, 2004 11:53 am Post subject: |
|
|
I did some changes to recmail to work with email with the message not attached. This is my first lines of perlcode I ever write, which reflects the quality ..
Code: |
$reldir = "msgstore";
$txt_mail = "";
umask( 0 );
while ( $line = <STDIN> )
{
if ($line =~ /:/)
{
@tmp = split( ": ", $line );
if ( lc($tmp[0]) eq "to" )
{
chop( $tmp[1] );
$to = $tmp[1];
}
elsif ( lc($tmp[0]) eq 'from' )
{
chop( $tmp[1] );
$from = $tmp[1];
}
elsif ( lc($tmp[0]) eq 'subject' )
{
chop( $tmp[1] );
$subject = $tmp[1];
$subject =~ s/=C3=A5/å/g;
$subject =~ s/=C3=A4/ä/g;
$subject =~ s/=C3=B6/ö/g;
$subject =~ s/=C3=85/Å/g;
$subject =~ s/=C3=84/Ä/g;
$subject =~ s/=C3=96/Ö/g;
$subject =~ s/^=.UTF-8.Q.//g;
$subject =~ s/.=$//g;
}
elsif ( lc($tmp[0]) eq 'content-type' )
{
# last;
$lastheader = 1;
}
}
else
{
if ($lastheader eq 1) { $txt_mail .= $line; }
}
}
|
Which also fixes the swedish characters. I had to remove that last, it seems to work without it, but probebly some new way to find the end of file is needed.
And to write the message.
Code: |
$txt = getTextForMid( $mid );
if ( length( $txt ) > 0 )
{
setTextForMid( $mid, $txt );
}
else
{
$txt_mail =~ s/=C3=A5/å/g;
$txt_mail =~ s/=C3=A4/ä/g;
$txt_mail =~ s/=C3=B6/ö/g;
$txt_mail =~ s/=C3=85/Å/g;
$txt_mail =~ s/=C3=84/Ä/g;
$txt_mail =~ s/=C3=96/Ö/g;
setTextForMid( $mid, $txt_mail );
}
|
It seems to work great for my setup atleast.
Thanks for your help. |
|
Back to top |
|
 |
Peffis Site Admin
Joined: 09 Sep 2003 Posts: 324 Location: Sweden
|
Posted: Tue Aug 17, 2004 11:57 am Post subject: |
|
|
Cool! Thanks for the feedback. I'll try it out... |
|
Back to top |
|
 |
Peffis Site Admin
Joined: 09 Sep 2003 Posts: 324 Location: Sweden
|
Posted: Tue Aug 17, 2004 11:59 am Post subject: |
|
|
Btw, what does your operator do if you insert more than one text message to a message? Like one text on page one and one text on page two in the MMS. Will they both appear in the "text" part of the email or will one of them get attached? I'm just curious... |
|
Back to top |
|
 |
joel Guest
|
Posted: Tue Aug 17, 2004 2:24 pm Post subject: |
|
|
noticed now that it actually doesnt work as I would like it too, attached images sometimes gets parsed aswell. Ohwell, back to try to fix it. Will post it here when I get it to work 100%. |
|
Back to top |
|
 |
joel Guest
|
Posted: Tue Aug 17, 2004 3:07 pm Post subject: |
|
|
Finally got the idea whats going on.
You probebly already know this,..
1. The phone sends MMS with pictures and text as multipart
2. The phone sends MMS without pictures with the text in the message, ie without attachment.
To save me some money when I was trying to find out why the message (only the subject) didnt reached the web I sent without pictures. I worked that one out now, so it works, useless feature but anyway, might be good to have anyway.
BUT, sending a message with picture and text still doesnt work for me. The problem seems to be that its not recored in the info.txt file. The messagefile is stored as <somerandomnumber>.desc (probebly the date or something, the phone makes it up).
In the .desc file the message is, but its never entred into the database since its not parsed by recmail.pl (since its not in the info.txt). The reason for this seems to be because the phone actually doesnt send any filename. Or atleast could be it?
Any hints how i proceed?  |
|
Back to top |
|
 |
Peffis Site Admin
Joined: 09 Sep 2003 Posts: 324 Location: Sweden
|
Posted: Tue Aug 17, 2004 3:51 pm Post subject: |
|
|
Try another thing. munpack (the program that extracts the parts) has a -t switch. Keep your recmail.pl as I had it (with your ÅÄÖ additions) and simply try and add that instead. I haven't tried this but I found a man page for munpack and it looks promising.
Code: | -t Also write the text MIME parts of multipart messages as files. By
default, text parts that do not have a filename parameter do not get
unpacked. This option effectively disables the ".desc" file feature
for MIME messages. |
|
|
Back to top |
|
 |
joel Guest
|
Posted: Tue Aug 17, 2004 8:26 pm Post subject: |
|
|
When trying munpack -t on my mailbox file (only one message) it creates a seperat message for the textpart. But when using it in the recmail script it simply doesnt work at all, no files are stored.
Do you know a simple way to debug whats going on?
Thanks. |
|
Back to top |
|
 |
Peffis Site Admin
Joined: 09 Sep 2003 Posts: 324 Location: Sweden
|
Posted: Tue Aug 17, 2004 8:48 pm Post subject: |
|
|
I know of no simple way to debug perl than to make prints here and there in the code. The munpack -t was just a guess. Don't know why it behaves as it does though. |
|
Back to top |
|
 |
Peffis Site Admin
Joined: 09 Sep 2003 Posts: 324 Location: Sweden
|
Posted: Wed Aug 18, 2004 8:16 am Post subject: |
|
|
Another way to solve it could be to simply add the content of the desc file as "text/plain" after the foreach loop in recmail where content is stored. Only if it's none empty that is. Add this after the storeContent loop but before the getTextForMid call and it should be ok I think.
One way to read the content of a file can be observed in the getTextForMid function. You only have to be able to determine the name of the .desc file but this you can do by looping over all files in the directory or something similar. |
|
Back to top |
|
 |
joel Guest
|
Posted: Wed Aug 18, 2004 8:39 am Post subject: |
|
|
I will make it a try ... hopefully I can get it to work, I will post what I did here when im done. |
|
Back to top |
|
 |
Peffis Site Admin
Joined: 09 Sep 2003 Posts: 324 Location: Sweden
|
Posted: Wed Aug 18, 2004 2:12 pm Post subject: |
|
|
Just to let you know, I've done some tries by implementing this script in PHP instead. It turns out that it's much easier, does not require munpack, and gives much more control over the parsing. The advantage of course is that one can share configuration files with the web-stuff and also some common subroutines.
It does not seem to have any of the limitations that munpack seem to have (with the missing message or the awkwardness of the .desc file).
I'll publish it here as soon as I have something up and running.
/S |
|
Back to top |
|
 |
joel Guest
|
Posted: Wed Aug 18, 2004 3:01 pm Post subject: |
|
|
Sounds great. No problem for me, I have php cli installed ..
Shouldnt it be easier to store the mailmessage first in a file, instead of reading STIND, that way you (me) could rerun the script in case of needing.
Thanks! |
|
Back to top |
|
 |
|