Web Hosting Forum | Lunarpages

Author Topic: problem subject in tfmail.pl  (Read 4833 times)

Offline sama

  • Newbie
  • *
  • Posts: 4
problem subject in tfmail.pl
« on: July 14, 2013, 10:22:38 PM »
HELLO
I've uploaded  script TFmail.pl
and I modify this line to
use constant CHARSET => 'UTF-8';
Is very good
 it sent the email body in Arabic
But faced this problem
Subject
    انا
Although it sent the  email body in Arabic
But the subject appeared in this way and did not read the Arabic language
can you solve this problem?
Thank you very much

Online MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6210
Re: problem subject in tfmail.pl
« Reply #1 on: July 15, 2013, 05:09:05 AM »
This might be of help: http://ncona.com/2011/06/using-utf-8-characters-on-an-e-mail-subject/

Apparently the default for a subject line is ASCII (or maybe Latin-1), but there are apparently tricks to get UTF-8 text there. You may have to modify the mailer code a little to get it to base 64 encrypt the subject line, and add a wrapper around it (per referenced article).
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

Offline sama

  • Newbie
  • *
  • Posts: 4
Re: problem subject in tfmail.pl
« Reply #2 on: July 15, 2013, 12:06:08 PM »

Thank you for your interest :smiling:


I found this code and I used this code in TFmail.pl

$subject = mimeencode($subject, 'UTF-8');
sub mimeencode {
my ($str, $enc) = @_;
return $str unless $str =~ /[[:^ascii:]]/;
my @parts;
while ( $str =~ /(.{1,40}.*?(?:\s|$))/g ) {
my $part = $1;
push @parts, MIME::QuotedPrint::encode($part, '');
}
join "\r\n\t", map { "=?$enc?Q?$_?=" } @parts;

};
subject has been sent successfully Arabic
subject:مشكلة
I thought the problem was solved
But I discovered a new problem
this code sends only one word in Arabic, but if I wrote two words that appear strange symbols
مشكلة وحلها
Appeared this
subject   =?UTF-8?Q?=D9=85=D8=B4=D9=83=D9=84=D8=A9 =D9=88=D8...
please Help me

Online MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6210
Re: problem subject in tfmail.pl
« Reply #3 on: July 15, 2013, 05:22:46 PM »
Try using
Code: [Select]
use MIME::Base64;and something more like
Code: [Select]
return "\r\n\t=?$enc?B?". base64_encode($str) . "?=";
(see http://www.caveofprogramming.com/perl/perl-base64/)
I don't know what you're trying to do with the loop and the 1-to-40 characters and the Q (quoted string) encoding.
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

Offline sama

  • Newbie
  • *
  • Posts: 4
Re: problem subject in tfmail.pl
« Reply #4 on: July 17, 2013, 07:53:43 PM »

Thank you very much :smiling: :smiling:
Thank you for your response
 I apologize to you because you are tired in reply to my question
Unfortunately, I tried your advice but does not benefit
I'm in this problem more than a month
Experimented with many codes but no solution
Encouraged me your answer and tried your advice but
I can not unfortunately solution
If possible, tell me where you put these codes
Especially this code is not working and gives the error page
return "\r\n\t=?$enc?B?". base64_encode($str) . "?=";

Online MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6210
Re: problem subject in tfmail.pl
« Reply #5 on: July 18, 2013, 06:02:42 AM »
I was suggesting that you follow the referenced pages and rewrite your code to use a different (B instead of Q) encoding, and a different base64 encoding method. This assumes you have some idea what you're doing in Perl code. If you're just blindly typing in code and not understanding what you're doing, STOP. Things will not improve. Find someone who knows Perl to do it for you. I will try to remember to get to rewriting your code tonight or this weekend, if I have time and you haven't reported it as being resolved by then.
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

Offline sama

  • Newbie
  • *
  • Posts: 4
Re: problem subject in tfmail.pl
« Reply #6 on: July 19, 2013, 07:57:58 PM »
I apologize to you and appreciate your interest
Thank you very much for answering my question
I hope that you remember this code
Thank you very much :smiling: :smiling:

Online MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6210
Re: problem subject in tfmail.pl
« Reply #7 on: July 20, 2013, 07:21:34 AM »
Try
Code: [Select]
$subject = mimeencode($subject, 'UTF-8');
sub mimeencode {
  my ($str, $enc) = @_;
  return $str unless $str =~ /[[:^ascii:]]/; # if all ASCII characters, just use this for the subject
###   I'm not sure what it's doing here... chunks of 1 to 40 characters?
#  my @parts;
#  while ( $str =~ /(.{1,40}.*?(?:\s|$))/g ) {
#     my $part = $1;
#     push @parts, MIME::QuotedPrint::encode($part, '');
#  }
#  join "\r\n\t", map { "=?$enc?B?$_?=" } @parts;  # implicitly returned string
   return "\r\n\t=?$enc?B?" . MIME::base64_encode($str) . "?=";
}

I can't guarantee it would work, but it's worth a try. If it doesn't, I don't work enough with UTF-8 email to go beyond that.
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

 

Share |