Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Correct type for jpg attachment?

Quote Reply
Correct type for jpg attachment?
Hi,

I'm trying to attach a jpg image to an email (using the following code) but after it's downloaded if I try to open the image it's saying the image contains no data. If I try to open it in photoshop it says the marker segment length is too short.

I can successfully open the original jpg file directly in my browser (off my server - the one it's sending) so it must be something I've done here with the type or encoding to stuff it up between being sent and me opening it?

$mail->attach (
type => 'image/jpeg',
encoding => '-guess',
body_path => '/path/to/file',
filename => "12587.jpg"
);

Anyone know?

Cheers,
Regan.

Quote Reply
Re: Correct type for jpg attachment? In reply to
Hi,

Can you send me the full email so I can see what the format looks like?

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Correct type for jpg attachment? In reply to
In case anyones looking for the same answer, you can thank Alex for this one! :)

image/jpeg is the right type for sending a jpeg attachment, my problem was that where it says "body_path" I had only entered a 'path' and not included the actual file into it.

body_path => '/path/to/image',
filename => "filename.jpg"


# Add the jpeg attachment to it
$mail->attach (
type => 'image/jpeg',
encoding => '-guess',
body_path => '/path/to/image/filename.jpg',
filename => "filename.jpg"
);
# send the file
$mail->send() or die "Error sending mail.\n\n";