Hi,

I am trying to send out HTML emails using MIME::Lite with inline images.

Unfortunately Google does not display the images, instead it gives the "display images below" message. Is there anyway to get around this?

Here is the code I am using:
use warnings; use strict; use Carp; use MIME::Lite; use Net::SMTP::SSL; sub send_mail { # Function parameters - replaced by absolute values my $to = 'someone@gmail.com'; my $subject = "Test"; my $from = 'someoneelse@gmail.com'; my $password = "someoneelsepassword"; ## Beautification code my $from_mime = $from; my $count = @_; if( $count ) { my $from_name = shift; $from_mime = "\"$from_name\" <$from>"; } ## End of Beautification code my $msg = MIME::Lite->new ( From => "$from_mime" , To => "$to" , Subject => "$subject" , ); $msg->attach( Type => 'text/html', Data => qq{ <body> Here's <i>my</i> image: <img src="cid:cpan.png"> </body> }, ); $msg->attach( Type => 'image/png', Id => 'cpan.png', Path => 'cpan_banner.png', ); my $smtp; if (not $smtp = Net::SMTP::SSL->new('smtp.gmail.com', Port => 465, Debug => 1)) { croak "Could not connect to server\n"; } $smtp->auth( $from, $password ) || croak "Authentication failed!\n"; $smtp->mail($from . "\n"); my @recepients = split(/,/, $to); foreach my $recp (@recepients) { $smtp->to($recp . "\n"); } $smtp->data(); $smtp->datasend( $msg->as_string() ); $smtp->dataend(); $smtp->quit; } send_mail();

In reply to MIME::Lite inline images by tmharish

Title:
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, details, 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, summary, 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.