Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I send Mime attachments?

Sending email

How do I send Mime attachments?

by  MikeLacey  Posted    (Edited  )
Please browse through faq219-2884 and faq219-2889 first. Comments on this FAQ and the General FAQ are very welcome.

use MIME::Lite;

### Create a new multipart message:
$msg = MIME::Lite->new(
From =>'me@myhost.com',
To =>'you@yourhost.com',
Cc =>'some@other.com, some@more.com',
Subject =>'A message with 2 parts...',
Type =>'multipart/mixed'
);

### Add parts (each "attach" has same arguments as "new"):
$msg->attach(
Type =>'TEXT',
Data =>"Here's the GIF file you wanted"
);
$msg->attach(
Type =>'image/gif',
Path =>'/usr/local/tmp/aaa000123.gif',
Filename =>'logo.gif'
);

$text = $msg->as_string;

## MIME::Lite also includes a method for sending these
## things.

$msg->send;

The "Path" attribute is the full path to the file you are sending.

The "Filename" attribute is the filename that will be displayed to the person who receives the email.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top