[ic] HTML Confirmation / HTML ship_notice
Mike Heins
mike at perusion.com
Sun Aug 28 10:50:00 EDT 2005
Quoting Adrian P Wilkinson (junk at puffin.org):
> Howdy,
>
> I've reviewed the list archive concerning sending HTML emails and have only
> come across a "this should work" posting rather than a confirmed working
> one, but I've used the theoretical example in my ship_notice as follows:
You will need to put this in your headers:
Content-Type: multipart/alternative; boundary="[tag op=mime arg=boundary /]"
for it to work properly.
I just put a new [email ...] tag in CVS. It accepts a separate file or
variable as a source of attachments and does all the formatting for you.
[tmp some_mess]<html><etc></etc></html>[/tmp]
[email
to="foo at bar.com"
subject="Test
html="[scratch some_mess]"
]This is the text message.[/email]
It magically creates the headers for a multipart/alternative combined
text-and-html message.
(CVS log comment follows)
* Enhance [email ...] tag to handle attachments. Requires MIME::Lite module,
which I have added to Bundle::Interchange[KitchenSink].
* To do the common request of HTML messages, you simply add an html parameter
thusly:
[email
from=foo at bar.com
to=bar at foo.com
subject=test
html="[scratch some_big_hairy_mess]"
]This is the plain text part.[/email]
This sets the main message type as multipart/alternative, automatically
sets the content-type and disposition of the two parts, and creates a
valid text-and-HTML message.
* To add a single file as an attachment, you just do:
[email
from=foo at bar.com
to=bar at foo.com
subject=test
attach=foo.gif
] Here is the gif file I promised. [/email]
It automatically picks up the MIME type, and handles many if you
have the optional MIME::Types module installed.
* To add multiple files, or for more control over the attachments,
the attach option accepts hashes.
[email
from=foo at bar.com
to=bar at foo.com
subject=test
attach.0=`{
type => 'image/gif',
path => 'images/foo.gif',
}`
attach.1=`{
type => 'image/jpeg',
path => 'images/foo.jpg',
}`
] Here are the files I promised. [/email]
This would be the same as:
[email
from=foo at bar.com
to=bar at foo.com
subject=test
attach=`[
{
type => 'image/gif',
path => 'images/foo.gif',
filename => 'PrettyName.gif',
},
{
type => 'image/jpeg',
data => $Tag->file('tmp/foo.jpeg')
|| $Tag->file('images/broken.jpg'),
filename => 'PrettyName.jpg',
},
]`
] Here are the files I promised. [/email]
--
Mike Heins
Perusion -- Expert Interchange Consulting http://www.perusion.com/
phone +1.765.647.1295 tollfree 800-949-1889 <mike at perusion.com>
For a successful technology, reality must take precedence over public
relations, for Nature cannot be fooled. -- Dick Feynman
More information about the interchange-users
mailing list