sub sendemail { $j = 0; foreach $i(@names){ ## Grab user info from the table $name = $names[$j]; # Get their name $email = $emails[$j]; # Get their email $subkey = $subkeys[$j]; #Get their subscriber key $remotehost = $ENV{'HTTP_HOST'}; $remotehost = "http://" . $remotehost . "/"; $locunsubscribe = 'perl/nl_unsubscribe.pl' . '?' . $subkey; $locunsubscribe = $remotehost . $locunsubscribe; mailit(); $j++; } } sub mailit{ print "

...Attempting to send message to user:"; print "

Record for $user

"; print ""; print "
"; my $wai = 'Wilcox Associates Inc.'; my $when = localtime(); my $locwai = '../Contactinfo/feedback.htm'; my $mail_host = 'mail.wilcoxassoc.com'; # Replace w/ browse button on form to get these. my $fullpath = 'd:\temp\test.pdf'; my $filename = 'test.pdf'; ### Create the multipart container $msg = MIME::Lite->new ( From => $wai, To => $email, Subject => $subject, Type =>'multipart/mixed' ) or die "Error creating multipart container: $!\n"; ### Add the text message part $msg->attach ( Type => 'TEXT/HTML', Data => "

Dear $name,

$body

To unsubscribe from the WAI Newsletter, follow this link: $locunsubscribe
THIS IS AN AUTOMATED MESSAGE! PLEASE DON'T REPLY TO THIS EMAIL." ) or die "Error adding the text message part: $!\n"; ### Add the specified PDF file $msg->attach ( Type => 'application/pdf', Path => $fullpath, Filename => $filename, Disposition => 'attachment' ) or die "Error adding $fullpath: $!\n"; ### Send the Message MIME::Lite->send('smtp', $mail_host, Timeout=>60); $msg->send or push @notsent,$email; }