×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Corruption of GIF image in email via MIME::Lite
2

Corruption of GIF image in email via MIME::Lite

Corruption of GIF image in email via MIME::Lite

(OP)
I seem to be getting a corruption when I email an in-line embedded GIF.

Here is the original file that was uploaded via my web app, it saved correctly and displays on the web page absolutely fine....



When a new banner is added to the system, a copy of the banner is sent to certain employees as a notification that the banner is live along with details of clickthrough tracking, expiry date of the advert , location on the extranet etc..

I have added several JPG / PNG static files without problems and the email received displays them fine, however the above image is appearing in the email as follows...



And as you can see all the animation is also missing.

Why is this happening?

I'm reading the file using

CODE

# read image file to raw binary and set for result
local $/ = undef;
open (my $img, '/images/banners/' . $banner[0]{'Page'} . '_' . $banner[0]{'RecID'} . '.' . $banner[0]{'Ext'}) or die $!;
binmode $img;
$result->{data}->{raw} = <$img>;
close $img; 

Which is passed to the emailing module that performs the MIME::Lite method...

CODE

$msg->attach( 
Encoding => 'base64',
Type     => 'image/' . $img->{ext},
Data     => $img->{raw},
Id       => $img->{id},
Disposition => 'inline'
 ); 


And then marked up in the email like so...

CODE

<img src="cid:<tmpl_var name='img'>" title="<tmpl_var name='tooltip'>" alt="<tmpl_var name='tooltip'>" /> 

The image is only 95kb in size so it can't be a size issue, it also appears to always happen when ever I use a GIF image regardless of it containing animation or just being a static GIF.

Something I am doing must be corrupting the image information somehow?

Your advise is very much appreciated.
1DMF

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

RE: Corruption of GIF image in email via MIME::Lite

(OP)
Well I've been bashing my head all day with the nice folks on Perl IRC and had to re-write my MIME::Lite TLS hack and replace Net::SMTP::TLS with Net::SMTPS as even basic HTML emails were being corrupted by Net::SMTP::TLS.

So I wanged the refactor over to the new system and tested sending the banner advert email and it's sorted the corruption.

I don't know what Net::SMTP::TLS was doing to my emails by it was doing something weird!

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

RE: Corruption of GIF image in email via MIME::Lite

(OP)
I've been running the refactor for a week now and all seems good.

I have updated my MIME::Lite TLS page with the new changes : http://dance-music.org/mime-lite-tls-email-encrypt...

The module has had a few improvements made, but the core change is the update of the mimelite hack to use Net::SMTPS instead of Net::SMTPS::TLS...

CODE

#######################
# MIME::Lite TLS Hack #
#######################
sub mimehack {                        
            
    @MIME::Lite::SMTPS::ISA = qw( Net::SMTPS ); 
    sub MIME::Lite::SMTPS::print { shift->datasend(@_); }
                
    # Add MIME::Lite hack to support TLS authentication / encryption         
    *MIME::Lite::send_by_smtp_tls = sub { 
        
        # Set objects & arguments
        my($self, $sendmail, @args) = @_; 

        # Create SMTPS client:                  
        eval
        {                                    
                                
            my $smtp = MIME::Lite::SMTPS->new(@args);   
            $smtp->mail($self->get('From'));          
            $smtp->to($self->get('To'));    
            $smtp->cc($self->get('Cc')); 
            $smtp->bcc($self->get('Bcc'));                                                                      
            $smtp->data(); 

            # MIME::Lite can print() to anything with a print() method: 
            $self->print_for_smtp($smtp); 
            $smtp->dataend();
            $smtp->quit();  
                    
        }; 

        # check for TLS errors and set warnings
        $sendmail->warning($@) if $@;                   

        return ($@)?0:1;     
        
    }; 
                  
} 

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

RE: Corruption of GIF image in email via MIME::Lite

Nice one...

Mike


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close