Sending html mail with inline images

S

Sebastian Scholz

Hi

I wrote a small script to send a html mail with inline images using
mail:sender. Sending html mails without the images works fine, but when I
try to have the images sent with the mail I only get the html and the image
attached to the mail. I used the example for the mail:sender module but that
did not work. Here is my code snippet :

sub smtpmailer{

eval {
(new Mail::Sender)
->OpenMultipart({
smtp => 'mailserver',
from => 'my\@mailadress.com',
to => 'recepients\@mailadress.com',
auth => 'LOGIN',
authid => 'mymail login',
authpwd => 'my password',
subject => 'HTML Mail TEST',
boundary => '1234567890'
})

->Part({ ctype => 'multipart/related'
})
->Part({ ctype => 'text/html',
disposition => 'attachment',
msg => $htmlfile
})
->Attach({
description => 'test gif',
ctype => 'image/gif',
encoding => 'base64',
disposition => "inline;
filename=\"testygify.gif\";\r\nContent-ID:<img1>",
file => $imgfile
})
->EndPart("multipart/related")
->Close()
}
or die "Cannot send mail: $Mail::Sender::Error\n";


}


$htmlfile and $imgfile are the pathes to the files. Well, like I said,
sending that mail works but the html page is not displayed, just attached.

Any idea what is wrong ? I am also willing to use another method, but I need
a way to login onto the smtp server.

Thanks alot.

Sebastian
 
S

Sebastian Scholz

Thanks, but MIME::Lite does not seem to be enable me to login onto the smtp
server as I can with Mail::Sender ..... or am I wrong ?

Sebastian
 
T

Tintin

[snipped MIME::Lite example]
Thanks, but MIME::Lite does not seem to be enable me to login onto the smtp
server as I can with Mail::Sender ..... or am I wrong ?

MIME::Lite either uses sendmail or makes use of Net::SMTP
 
G

Gunnar Hjalmarsson

Sebastian said:
I wrote a small script to send a html mail with inline images using
mail:sender. Sending html mails without the images works fine, but
when I try to have the images sent with the mail I only get the
html and the image attached to the mail. I used the example for the
mail:sender module but that did not work. Here is my code snippet :
->Part({ ctype => 'text/html',
disposition => 'attachment',
msg => $htmlfile
})

That does not look right. Try this instead:

->Attach({ ctype => 'text/html',
disposition => 'NONE',
file => $htmlfile
})
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top