my $msg = MIME::Lite->new( From => $from_address, To => $email_address, Subject => $subject, Type => 'text/html', Data => $template->output() ); #we need to add any images to the mail if they exist my $parser = HTML::LinkExtor->new(); $parser->parse($template->output()); foreach my $link ($parser->links){ if ($link->[0] eq 'img'){ my_print("Image found [".$link->[2]."] "); if ($link->[2] =~ /^https?:\/\//){ my_print("Absolute! Ignored.\n"); }else{ my ($imgtype,$junk) = reverse split '\.',$link->[2]; $imgtype =~ s/^jpg$/jpeg/; #propper mime name? if(open(TEST,"<".$link->[2])){ my_print("Attaching\n"); close(TEST); $msg->attach(Type =>'image/'.$imgtype, Path =>$link->[2], Filename=>$link->[2], #Disposition => 'inline'); Disposition => 'attachment'); }else{ my_print("Not found, Skipped!!\n"); } } } } if($opts{'d'}){ #debug mode my_print($msg->as_string); }else{ $msg->send(); }