I've a problem with the Mail::Sender module. Basically I want to send an HTML E-mail with an embedded image to Outlook. The following code is based on the mod's documentation but isn't working, the html file and image file arrive as attachment's not as the message.
Can anyone please help?
#!/usr/local/bin/perl -w
use strict;
use Mail::Sender;
my $sender = new Mail::Sender { smtp => 'myserver.com' };
$sender->OpenMultipart( {
from => 'Jonathan@myserver.com',
to => 'Jonathan@anotherbox.com',
subject => 'Embedded image test',
subtype => 'related',
boundary => 'boundary-test-1',
type => 'multipart/related'} );
$sender->SendFile ( {
description => 'html body',
ctype => 'text/html; charset=us-ascii',
encoding => '7bit',
disposition => 'NONE',
file => 'test.html'} );
$sender->SendFile ( {
description => 'Company logo',
ctype => 'image/gif',
encoding => 'base64',
disposition => "inline; filename=\"picture.gif\";\r\nC
+ontent-ID,
file => 'picture.gif'} );
$sender->Close();
__END__
And the html file test.html
<HTML>
<BODY BGCOLOR=#87CEFA TEXT=#000000>
<TITLE>Test message</TITLE>
<IMG SRC="cid:ed1"><BR>
<BIG><BIG><B><U>This is a test message</U></B></BIG></BIG>
</BODY>
</HTML>
"I have read your book, and it is both good and original. But what is good is not original, and what is original is not good."
- Samuel Johnson
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.