Jugger has asked for the wisdom of the Perl Monks concerning the following question:

Hey hey, can anyone help me i'm stuck getting my email to work properly.....
Heres my code
my $msg = MIME::Lite->new( From =>'me@myhost.com', To =>'mehomeemail@myhost.com', Subject =>'Test Message', Type =>'multipart/mixed' ); # Add the text message part: $msg->attach(Type =>'TEXT', Data =>"Here goes" ); # Add the image part $msg->attach(Type =>'image/gif', Path=>'/foo/baa.gif', Disposition => 'attachment' ); # send it $msg->send();
This sends the mail ok but the attachment isnt shown, now
I've narrowed this down to the Header and more
specifically the Content-Type header of the part
relating to the image - it says....

Content-Type = "image/gif" name="baa.gif"

This works perfectly on a standard client say firefox but
non-standard - bespoke type mail clients have a
problem - basically I need to change the Content-Type
to....
Content-Type = "image/gif"

Thanks
Jugger

Replies are listed 'Best First'.
Re: Help with MIME::Lite
by kaif (Friar) on Jun 08, 2005 at 17:04 UTC

    Changing your code to

    $msg->attach(Type =>'image/gif', Path=>'/foo/baa.gif', Disposition => 'attachment' ) ->attr( 'content-type.name', undef );

    works. Here, I am using that attach returns the new part; you're probably more familiar with MIME::Lite than I am, so if you wish to separate this into two lines, you need to find some sort of accessors for parts --- I was unable to find them.

    I'm unsure if this is the recommended way of doing this; I think it should be fine.

      Whooohooo !!

      Thanks very much this works a treat :)

      Jugger
Re: Help with MIME::Lite
by fauria (Deacon) on Jun 08, 2005 at 16:48 UTC
    Have you tried creating a separate part for the image, and then attach it to the rest of the message? Using Thunderbird, image1 is shown whithin the message, and image2 as an attachment:
    ... $msg->attach( Type =>'image/gif', Path =>'/tmp/image1.gif', Disposition => 'attachment' ); my $part = MIME::Lite->new( Path => '/foo/image2.gif' ); $part->attr('Content-Type' => 'image/gif'); $msg->attach($part); ...
      Tried this but still the same the Content-Type was listed as...

      Content-Type: image/gif; name=image.gif

      Is there a way I can rip thru, line by line, $msg at all ??

      Thanks
      Jugger
Re: Help with MIME::Lite
by TedPride (Priest) on Jun 08, 2005 at 16:55 UTC
    You could also just dump the image in a folder and put a link to it in your email. Not as elegant perhaps, but it works.