Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 129
  • Last Modified:

Printing 2 Arrays??

here's my code.. $emailfile string for example would be "test-user1.html, test-user2.html" i want to break them up which i'm doing but how can i print it out??


my @mailnames=split(/ *, */,$mailperson) ;
foreach(@mailnames) {

open(SENDMAIL, "|$sendmail -t") || die "Unable to open sendmail";

print SENDMAIL "to: $_\n";
print SENDMAIL "BCC: $bccemail\n";
print SENDMAIL "CC: $ccemail\n";
print SENDMAIL "from: $fromname <$fromemail>\n";
#print SENDMAIL "Reply-to: $fromname <$fromemail>\n";
print SENDMAIL "MIME-Version: 1.0\n";
print SENDMAIL "subject: $subject\n";
print SENDMAIL "Content-Type: text/html; charset=us-ascii\n\n";


my @filenames=split(/ *, */,$emailfile) ;


open (HTMLFILE, "/usr/home/test/upload/ ?? ? ?? ??  ") || die "can't open HTML file: $!";
while (defined($line = <HTMLFILE>)) { print SENDMAIL $line; }
close (HTMLFILE) || die "can't close HTML file: $!";

}

close(SENDMAIL);

}


thanks
0
jmingo
Asked:
jmingo
  • 7
  • 3
1 Solution
 
jmingoAuthor Commented:
sorry, ignore the { in here

close (HTMLFILE) || die "can't close HTML file: $!";

}
0
 
ozoCommented:
{local @ARGV=map{"/usr/home/test/upload/$_},split(/ *, */,$emailfile);
  while( <> ){ print SENDMAIL; }
}
0
 
jmingoAuthor Commented:
so what does that replace?? what's the complete new code ??

thanks!
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jmingoAuthor Commented:
so this code is going to email a html file also right??
0
 
ozoCommented:
That replaces

  my @filenames=split(/ *, */,$emailfile) ;

  open (HTMLFILE, "/usr/home/test/upload/ ?? ? ?? ??  ") || die "can't open HTML file: $!";
  while (defined($line = <HTMLFILE>)) { print SENDMAIL $line; }
  close (HTMLFILE) || die "can't close HTML file: $!";

Assuming I understood what you meant to do with that code.
0
 
jmingoAuthor Commented:
that code causes an error. the script works when i take out your code... any ideas??? thanks again.

my @mailnames=split(/ *, */,$mailperson) ;

foreach(@mailnames) {

open(SENDMAIL, "|$sendmail -t") || die "Unable to open sendmail";

print SENDMAIL "to: $_\n";
print SENDMAIL "BCC: $bccemail\n";
print SENDMAIL "CC: $ccemail\n";
print SENDMAIL "from: $fromname <$fromemail>\n";
print SENDMAIL "MIME-Version: 1.0\n";
print SENDMAIL "subject: $subject\n";
print SENDMAIL "Content-Type: text/html; charset=us-ascii\n\n";


{local @ARGV=map{"/usr/home/winstorm/public_html/cma/upload/$_},split(/ *, */,$emailfile);
while( <> ){ print SENDMAIL; }
}

close(SENDMAIL);

}
0
 
jmingoAuthor Commented:
changed it to this

{local @ARGV=map "/usr/home/winstorm/public_html/cma/upload/$_" ,split(/ *, */,$emailfile);
while( <> ){ print SENDMAIL; }
}

works... kinda. but it sends 2 html files to each user. i want to send for ex. test-user.html to user1@here.com and test-user2.html to user2@here.com if i'm passing a URL like this

http://1.1.1.1/test.cgi?user=user1@here.com,user2@here.com&emailfile=test-user1.html,test-user2.html

thanks
0
 
ozoCommented:
So with
$mailperson = "user1@here.com,user2@here.com";
$emailfile="test-user1.html,test-user2.html";
you want to send test-user1.html to user1@here.com and test-user2.html to user2@here.com ?

my %filenames;
@filenames{split/\s*,\s*/,$mailperson}=split/\s*,\s*/,$emailfile;
foreach( keys %filenames  ){

open(SENDMAIL, "|$sendmail -t") || die "Unable to open sendmail";

print SENDMAIL "to: $_\n";
print SENDMAIL "BCC: $bccemail\n";
print SENDMAIL "CC: $ccemail\n";
print SENDMAIL "from: $fromname <$fromemail>\n";
#print SENDMAIL "Reply-to: $fromname <$fromemail>\n";
print SENDMAIL "MIME-Version: 1.0\n";
print SENDMAIL "subject: $subject\n";
print SENDMAIL "Content-Type: text/html; charset=us-ascii\n\n";

open (HTMLFILE, "<$filenames{$_}") || die "can't open HTML file: $!";
print SENDMAIL <HTMLFILE>;
close (HTMLFILE) || die "can't close HTML file: $!";

close(SENDMAIL);

}
0
 
jmingoAuthor Commented:
so if it was in an upload directory i'd put something like this

open (HTMLFILE, "/usr/local/test/upload/<$filenames{$_}") || die "can't open HTML file: $!";

???
0
 
jmingoAuthor Commented:
open (HTMLFILE, "</usr/home/winstorm/public_html/cma/upload/$filenames{$_}") || die "can't open HTML file: $!";


this did it... thanks so much for your help!!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 7
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now