SMS Server Tools 3
 Menu
Basic information:
Additional information:
Support:
Get SMS Server Tools 3:
Additional Options

 Sponsored links

 Search
Custom Search

 Visitor locations
 
 SMS Server Tools 3 Community
Welcome, Guest. The forum is currently read-only, but will open soon. Thu Nov 21, 2024 21:14
SMSTools3 Community » Bug reports Bottom

email2sms and quoted-printable

Login and Post Reply

Page:  1

Author Post
Member
Registered:
Nov 2009
Location: Finland
Hello again,

I don't know if I fixed this at the right point, but I had an issue with quoted-printable mails from our ticket system. The result was that I received messages where ä, ö and others were =C3, =A4 etc.

So, I wrote a small addition to email2sms -script, here's a diff for original email2sms (from this post):
38a39
>   TMPOUTFILE=$(mktemp /var/spool/sms/tmp/smsgw.out.XXXXXX)
40c41
<   formail -f -I "To: $destination" < $tmp > $OUTFILE
---
>   formail -f -I "To: $destination" < $tmp > $TMPOUTFILE

41a43
>   /usr/local/bin/decodequoted.pl $TMPOUTFILE > $OUTFILE
 
'diff' Syntax Highlight powered by GeSHi


And here's the (butt ugly) decodequoted.pl:
#!/usr/bin/perl

my $file = $ARGV[0];

unless(-e $file) {
        die "$file not found!\n";
}

# If there's no MIME -header just pass the file trough
# This IS NOT an fool proof way, but hopefully enough
my $mimetest=`grep '^MIME-Version' $file|wc -l`;
if($mimetest == 0) {
        open CONTENT, $file or die "ARRG!\n";
        while (<CONTENT>) {
                if($_ =~ /^To:\s+.*<(\S+\@\S+)>.*$/) {
                        print "To: ".$1."\n";
                } else {
                        print $_;
                }
        }
        exit 0;
}

my $metamail=`metamail -w -x -y $file`;
my @rows = split("\n",$metamail);

my $headers;
my $headerson=1;
my $tmpfile;
foreach (@rows) {

        if($headerson==1) {
                if($_ =~ /^To:\s+.*<(\S+\@\S+)>.*$/) {
                        $headers.="To: ".$1."\n";
                } else {
                        $headers.=$_."\n";
                }
        }

        if($_=~/^$/)  {
                $headerson=0;
        }

        if($_=~/^Wrote.file/) {
                $tmpfile=$_;
                $tmpfile=~s/Wrote.file.//;
        }
}
open CONTENT, $tmpfile or die "ARGG!\n";

print $headers."\n";
while (<CONTENT>) {
        print $_;
}

close CONTENT;
unlink($tmpfile);
unlink($file);
 
 
'perl' Syntax Highlight powered by GeSHi


This seems to work (with my needs), but if you break something you own all the parts ;) I have not tested this properly trough, so I don't have ANY idea about how it'll handle ie. multipart messages (ie. html & plaintext).

Obviously the real solution would be to rewrite original email2sms to handle quoted printable and other issues properly, but since I don't have the time for that right now I just wrote that workaround.

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
I almost guessed that this will be your next topic. ;)

Thank's for providing a workaround, it surely may be useful for other users.

However, I do not see this as a bug. It's a limitation of the original script, only plain text is supported. Right now I do not have plans for enhancing the script to handle any formats properly, because it would be a too big work. Perhaps some external program could be found to do this conversion, but I do not know of them.

See also this script which is provided by edo: email2sms-ucs: international version of email2sms. It may work better (I have not tested it), but it does not send to multiple recipients. It could be modified for that, but also a checkhandler can be used to create message files for more than one recipient.

Member
Registered:
Nov 2009
Location: Finland
Topic owner
keke wrote
However, I do not see this as a bug. It's a limitation of the original script, only plain text is supported. Right now I do not have plans for enhancing the script to handle any formats properly, because it would be a too big work. Perhaps some external program could be found to do this conversion, but I do not know of them.

I agree, this isn't a bug per definition, but since result look like one I suppose bug repots
is proper place for the discussion.

I also agree that actually fixing that is an huge work, since there's a lots of to take care of, basically you'd need to have almost fully functional email ciient with full MIME-suppport to really fix this. I did try to write something as dirty as that previous perl-thingy with MIME-tools, but it would take a much more time than I have to spare now.

However, this would be an great improvement for sms3tools, since properly functioning email2sms -gateway helps integrating sms3tools to other services (virtually for any purpose).

Another big improvement would be an framework, which would take care of incoming messages and launch commands, send email etc. accordingly, but that's a whole another topic.

Member
Registered:
May 2010
Location: Russian Federation
keke wrote
See also this script which is provided by edo: email2sms-ucs: international version of email2sms.

yes, it must support any MIME encoding, including quoted-printable.

Quote
It may work better (I have not tested it), but it does not send to multiple recipients.

in my configuration smtp server will process multiple recipients correctly (it call script independently for every recipient).

Login and Post Reply

Page:  1

SMSTools3 Community » Bug reports Top

 
Time in this board is UTC.  

Privacy Policy   SMS Server Tools 3 Copyright © Keijo Kasvi.