Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Have you considered MIME::Lite ?

It has the advantage that you can build up your own mime mail components. I was faced with a similar problem to yours in the past. I didn't need to use multiparts but I did do image inserts I used HTML::LinkExtor to grab all the images in the HTML page. I've included a code snippit if it will help:-

  • my_print() is my "special" debug print statement (only prints if debug enabled)
  • $opts is my command line arguments hash $opts{'d'} was for debug :)
  • $template was an HTML::Template object
  • the script assumes that images to attach are local to its directory
Hope this helps
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(); }

---If it doesn't fit use a bigger hammer

In reply to Re: Sending HTML email w/images + attachment by vagnerr
in thread Sending HTML email w/images + attachment by Xaositect

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (13)
    As of 2015-11-30 09:04 GMT
    Find Nodes?
      Voting Booth?

      What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

      Results (767 votes), past polls