Hi all,
I want to send a file as attachment every few hours (using cron)
The file is a binary file and merely appending(using mail command) does not suffice.
Kanti
_________________________________________________________ There is always a better job for you at Monsterindia.com. Go now http://monsterindia.com/rediffin/
On 19 Jun 2002, Kanti Jadia wrote:
I want to send a file as attachment every few hours (using cron)
The file is a binary file and merely appending(using mail command) does not suffice.
First, add this header to the message:
Content-type: multipart/mixed; boundary="some_string_of_text" MIME-Version: 1.0
start your mail with the normal body, and then any attachments you want, encoded with mimeencode:
--some_string_of_text Content-type: text/plain
This is the body of the mail
--some_string_of_text Content-Type: application/octetstream Content-Transfer-Encoding: base64
ENCODED ATTACHMENT HERE
--some_string_of_text--
_END_OF_MAIL_
I could send you a program that does this, but I'm feeling too lazy right now.
Philip wrote:
On 19 Jun 2002, Kanti Jadia wrote:
I want to send a file as attachment every few hours (using cron)
The file is a binary file and merely appending(using mail command) does not suffice.
First, add this header to the message:
Content-type: multipart/mixed; boundary="some_string_of_text" MIME-Version: 1.0
....
I could send you a program that does this, but I'm feeling too lazy right now.
Why write a new program for such a simple task? Why not use Mail::Sender? Here is a simple script -
------------------------------------------------ #!/usr/bin/perl
use Mail::Sender;
if (!($ARGV[0])) { print "\n\tUsage: $0 <attachfilename> \n\n"; exit; } $file_name = $ARGV[0]; $smtp_server = 'your.smtp.server'; $sender_mail = 'Youyou@domain'; $recipients = 'YourRecipientrecipient@domain'; $mail_subject = 'Checkout the Attached File'; $msg_body = "\n\n Checkout the attachment";
$sender = new Mail::Sender { smtp => $smtp_server , from => $sender_mail }; $sender->MailFile( {to => $recipients, subject => $mail_subject, msg => $msg_body, file => $file_name }); $sender->Close; ------------------------------------------------
Regards, Nilesh C.
________________________________________________________________________ Want to sell your car? advertise on Yahoo Autos Classifieds. It's Free!! visit http://in.autos.yahoo.com