Discussion:
Send Mail with attachment
(too old to reply)
l***@gmail.com
2008-10-22 04:12:00 UTC
Permalink
Hi All,

I'm using perl module MIME::Lite to sent out email with attachments,
may I know what "Type" should I define to attach any type of files,
for instance .jpg, .xls, .doc, .pdf and etc without checking the
attached file type. Is there any global variable to define instead of
Type => 'application/zip', Type => 'image/gif', Type => "application/
xls" and etc?

$msg->attach (
Type => 'what type should I define without checking the attached
file type',
Path => '$path',
Filename => '$filename',
Disposition => 'attachment'
)

Please helps.

Thanks & Regards,
Leo.
Jeff Pang
2008-10-22 07:05:19 UTC
Permalink
Post by l***@gmail.com
Hi All,
I'm using perl module MIME::Lite to sent out email with attachments,
may I know what "Type" should I define to attach any type of files,
for instance .jpg, .xls, .doc, .pdf and etc without checking the
attached file type. Is there any global variable to define instead of
Type => 'application/zip', Type => 'image/gif', Type => "application/
xls" and etc?
I don't think there is one.
If you don't specify the types distinctly, you break the rules (RFC 2822 etc).
--
my @name = glob "{JeffP}{a,e}{ng}"
http://home.arcor.de/pangj/
Octavian Rasnita
2008-10-22 08:11:52 UTC
Permalink
Post by l***@gmail.com
Hi All,
I'm using perl module MIME::Lite to sent out email with attachments,
may I know what "Type" should I define to attach any type of files,
for instance .jpg, .xls, .doc, .pdf and etc without checking the
attached file type. Is there any global variable to define instead of
Type => 'application/zip', Type => 'image/gif', Type => "application/
xls" and etc?
You could use
Mail::Builder
to create the mail messages and and Email::Send to send them.

You should use something like:

use strict;
use warnings;
use Mail::Builder;
use Email::Send;

my $mail = Mail::Builder->new;
$mail->from('***@server.com');
$mail->to('***@anotherserver.com');
$mail->subject('Here is the subject');
$mail->plaintext('The plain text version');
$mail->htmltext('<b>The html</b> version');
$mail->attachment->add('file.pdf');
$mail->attachment->add('anotherfile.pdf');
$mail->image->add(image.jpg'); #An image you want to appear in the html file

my $mailer = Email::Send->new({mailer => 'SMTP'});
$mailer->mailer_args([Host => 'smtp.yourhost.com']);
$mailer->send($mail->stringify);

This module also encodes the headers as UTF-8, so they will be set correctly if the headers use special chars from other languages than english.
HTH.

Octavian
Stewart Anderson
2008-10-22 09:14:05 UTC
Permalink
Post by l***@gmail.com
Hi All,
I'm using perl module MIME::Lite to sent out email with attachments,
may I know what "Type" should I define to attach any type of files,
for instance .jpg, .xls, .doc, .pdf and etc without checking the
attached file type. Is there any global variable to define instead of
Type => 'application/zip', Type => 'image/gif', Type => "application/
xls" and etc?
$msg->attach (
Type => 'what type should I define without checking the
attached
Post by l***@gmail.com
file type',
Path => '$path',
Filename => '$filename',
Disposition => 'attachment'
)
Please helps.
I think that with MIME::Lite you can just set the type as BINARY or
TEXT. I experimented with lots of types for zip files and xls/csv
files and whilst is may break the RFC it does not seem to break how
the item is attached eg I send xls files as text and it made no
difference when the mail arrived in outlook with the attachement.

That's probably heresy though :)

Stu



Information in this email including any attachments may be privileged, confidential and is intended exclusively for the addressee. The views expressed may not be official policy, but the personal views of the originator. If you have received it in error, please notify the sender by return e-mail and delete it from your system. You should not reproduce, distribute, store, retransmit, use or disclose its contents to anyone. Please note we reserve the right to monitor all e-mail communication through our internal and external networks. SKY and the SKY marks are trade marks of British Sky Broadcasting Group plc and are used under licence. British Sky Broadcasting Limited (Registration No. 2906991), Sky Interactive Limited (Registration No. 3554332), Sky-In-Home Service Limited (Registration No. 2067075) and Sky Subscribers Services Limited (Registration No. 2340150) are direct or indirect subsidiaries of British Sky Broadcasting Group plc (Registration No. 2247735). All of the companies mentioned in this paragraph are incorporated in England and Wales and share the same registered office at Grant Way, Isleworth, Middlesex TW7 5QD.
Loading...