Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Sending mail via perl including inline images to gmail/yahoo

by Damian_derby (Initiate)
on Oct 06, 2011 at 20:33 UTC ( #930063=perlquestion: print w/replies, xml ) Need Help??
Damian_derby has asked for the wisdom of the Perl Monks concerning the following question:

Hi there, My issue is, and I've been at it all day now, no matter what I've tried, I cannot get inline images to work when the user receives the email via a gmail or yahoo account. I had been using MIME Lite, which works just fine for outlook/hotmail, images show up immediately with no message saying 'click here to see images'. Working as intended at this point! My question is, has anyone had success in sending emails using perl and receive the email on a gmail/yahoo account with inline images working. I've tried mail sender, mail sendmail, and mime lite so far. Below is the basic code I use currently, which again works as it should when it's going to an outlook/hotmail acount. The behavior I get from gmail is just always, 'click to display' and then all is well, but that causes an issue with that the most important thing in my email, is an image. With Yahoo, I actually can't get images to show at all, even when I click display images, they just don't; Although Yahoo is not a concern, just something else I noticed not working with current attempts.

my $msg = MIME::Lite->new( To =>'blah@blah.blah', from =>'inline@images@suq', Subject =>'HTML with in-line images!', Disposition =>'inline', Type =>'multipart/related' ); $msg->attach(Type => 'text/html', Data => qq{ <body> Here's <i>my</i> image: <img src="cid:twitter-white.jpg"> test </body> } ); $msg->attach(Type => 'image/jpeg', Id => 'twitter-white.jpg', Path => 'twitter-white.jpg', );

Replies are listed 'Best First'.
Re: Sending mail via perl including inline images to gmail/yahoo
by Khen1950fx (Canon) on Oct 06, 2011 at 22:53 UTC
Re: Sending mail via perl including inline images to gmail/yahoo
by zentara (Archbishop) on Oct 07, 2011 at 16:16 UTC
    I tested your code, and it "seemed" to work with Claws-mail. I did have to add base64 to your attachment list options. The image displayed inline, but it didn't have the cid:...... text identifier box above it, it acted like a regular attachment.
    $msg->attach(Type => 'image/jpeg', Id => 'twitter-white.jpg', Path => 'twitter-white.jpg', Encoding => 'base64', );

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://930063]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2018-04-21 06:02 GMT
Find Nodes?
    Voting Booth?