p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Perl (http://p2p.wrox.com/forumdisplay.php?f=196)
-   -   How to send attachments through a SMTP server (http://p2p.wrox.com/showthread.php?t=49317)

Pawan Sangal October 23rd, 2006 01:30 AM

How to send attachments through a SMTP server
 
Hello Friends,

I want to send attachments through a SMTP server.
Iam already sending mails through it (using Net::SMTP utility). But, till now Iam only able to send only messages and not with attachments.

Can anybody tell me how to send attachments while sending mails on other's mail id.

As, Iam novice to Perl, It will be greatly helpful for me if anyone can provide me a code for sending the attachment. So, I could be able to send both message and attachment together.

It will be better, if someone can guide me for that or using Net::SMTP utility.

Thanks in advance......
Pawan Sangal

ciderpunx October 24th, 2006 07:03 AM

It'd be a big job. Use MIME::Lite instead would be my advice.

http://search.cpan.org/~yves/MIME-Li...b/MIME/Lite.pm

HTH

--
Don't Stand on your head - you'll get footprints in your hair
                                           http://charlieharvey.org.uk
                                              http://charlieharvey.com

crmpicco November 16th, 2006 08:49 AM

Code:

#! /usr/bin/perl

# Craig R Morton

use MIME::Lite;

############ EMAIL ###############
# build email message
$msg = MIME::Lite->new(
            From => "noreply\@picco.net (Boab)",
            To => "craig\@picco.net",
            Subject => "Report (with CSV Attachment)",
            Type    => "multipart/mixed"
            );

$msg->attach(Type => "TEXT", Data => "Attached to this document is a CSV report of all confirmed bookings made within the last week by Picco\n\nThere have been $counter bookings made within the last week");
$msg->attach(Type => "text/plain", Path => "/web/picco/data/crmpicco.csv", Filename => "crmpicco.csv");

$text = $msg->as_string;

# send email message
$msg->send;
############ EMAIL ###############


www.crmpicco.co.uk
www.ie7.com

crmpicco December 7th, 2006 10:37 AM

Did that example work ok for you Pawan?

www.crmpicco.co.uk
www.ie7.com


All times are GMT -4. The time now is 09:20 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.