Hello!
Newbie here. I have never worked with jcode.pl or the new Jcode.
However, I am trying to get e-mail piping working with perldesk
(perldesk.com). Since I have never used Jcode, the instructions are
completely over my head. I would be grateful if anyone could help me fix
my file so that I can send and receive Japanese e-mails through this
script. The part I need to fix is as follows. I'll include the whole
file if necessary.
#!/usr/bin/perl
require "/home/www/include/conf.pl";
require "/home/www/include/lang/jp.inc";
use CGI qw(:standard);
use DBI();
use MIME::Parser;
use Mail::Address;
use MIME::Entity;
use MIME::Body;
use Data::Dumper;
$parser = new MIME::Parser;
$parser->ignore_errors(1);
$parser->output_to_core(1);
my $MIME_entity = $parser->parse(\*STDIN);
my $error = ($@ || $parser->last_error);
$header = $MIME_entity->head;
$subject = $header->get('Subject');
$cto = $header->get('To');
$from = $header->get('From');
@to_addresses = Mail::Address->parse($cto);
@from_addresses = Mail::Address->parse($from);
my $address;
if (@to_addresses) {
$to = $to_addresses[0]->address();
} else {
exit;
}
if (@from_addresses) {
$address = $from_addresses[0]->address();
} else {
exit;
}
if ($MIME_entity->parts > 0)
{
for (my $i=0;$i<$MIME_entity->parts;$i++)
{
my $subEntity = $MIME_entity->parts($i);
my $ignore_plain = 0;
my $ignore_html = 0;
$ishtml = "1" if $subEntity->mime_type eq 'text/html';
$ishtml = "0" if $subEntity->mime_type eq 'text/plain';
if (($subEntity->mime_type eq 'text/html') &&
($ignore_html == 0))
{
if (my $io = $subEntity->open("r"))
{
while (defined($_=$io->getline))
{ $_ =~ s/"/\"/g;
$body .= $_;
}
$io->close;
$ignore_plain=1;
}
}
if (($subEntity->mime_type eq 'text/plain') &&
($ignore_plain=0)) {
if (my $io = $subEntity->open("r")) {
while (defined($_=$io->getline))
{ $_ =~ s/"/\"/g;
$body .= $_;
}
$io->close;
$ignore_html=1;
}
}
}
}
else
{
$body = join "", @{$MIME_entity->body};
}
$to = $1 if $to =~ /<(\S+)>/;
if ($from =~ /<(\S+)>/) { $newfrom = $1 }
else { $newfrom = $from }
$body =~ s/"/\"/g;
if ((!$subject) ||
($subject eq ""))
{
open(MAIL, "|/usr/sbin/sendmail -t") || print "Unable
to send mail:
$!";
print MAIL "To: $newfrom\n";
print MAIL "From: $ticketad\n";
print MAIL "Subject: Help Desk
Response\n\n";
print MAIL "Please resend your request
with a subject line intact, if
you ";
print MAIL "are replying to a staff
response, please keep the subject
line intact for tracking purposes, if this is a new request, please give
it a suitable subject line.";
print MAIL "\n\n";
print MAIL "Thank You.";
close(MAIL);
exit;
}