I 'm trying to make a program to handle mailing within our department. The program asks a bunch of questions about the message to be sent, reads the body for a text or html file, then looks up people's e-mail addresses in a database, and uses Net::SMTP to loop over the results of that query and send the message to them. So far, so good. Now, I need to add attachments to these messages. Here's where I run into trouble. I think I've got a handle on MIME::Lite, but I need to find out what type of attachment they are sending, so I am using MIME::Types to try to figure that out. However, I keep getting the following error: illegal MIME: can't have encoding base64 with type multipart/mixed
Here's what my code looks like (I've taken out the querying stuff and am just using myself as a test message until I get it right): use DBI; ### Call the DBI module. We need this to get the addresses. use Net::SMTP; ### Call the Net::SMTP module. We need this to send the message. use MIME::Lite; ### Call the MIME::Lite module. We need this if we're to have attachments. use MIME::Types qw(by_suffix);### Call the MIME::Types module. We need this to figure out what we're sending. print "What should I use for a return address?\n"; chomp(my $return = <STDIN>); print "Where's the file that is the body of the message?\n"; chomp(my $body = <STDIN>); print "Is this message HTML formatted? (type Y or N)\n"; chomp(my $html = <STDIN>); print "Do you want to add an attachment? (type Y or N)\n"; chomp(my $atyn = <STDIN>); if ($atyn =~ m/Y/i){ print "What is the path to the attachment?\n"; chomp(my $attach = <STDIN>); } print "What would you like to use as a subject?\n"; my $subject = <STDIN>; print "Are you sure that you have entered the addresses into the database?\n(type Y to go on or N to quit)\n"; chomp(my $conf = <STDIN>); exit if ($conf =~ m/N/i); my $message = ""; open(BODY, $body); while (<BODY>){ $message = $message . $_; } if ($atyn =~ m/Y/i){ my ($atmt, $atenc) = by_suffix($attach); print "Mime Type of Attach: $atmt \nEncoding: $atenc\n"; } my $mimetype = "Content-type\: text\/PLAIN\n"; if ($atyn =~ m/Y/i){ $mimetype = "multipart/mixed\n"; }elsif (html =~ m/Y/i){ $mimetype = "text/html\n"; } $mtype = "TEXT"; if ($html =~ m/Y/i){ $type1 = "HTML"; } my $testadd = '[EMAIL PROTECTED]'; $msg = new MIME::Lite From =>"$return", To =>"$testadd", CC =>"", Subject =>"$subject", Type =>"$mimetype"; attach $msg type =>"$mtype", Data =>"Hello. I am Aaron's Simple Mailer Program. If this message is as you want it to appear, let him know so that he can send the rest of them.\n\n-=-=-=-=-=-=-=-=Begin Test Message Below=-=-=-=-=-=-=-=-=-=-\n $message"; if ($atyn =~ m/Y/i){ attach $msg type =>"$atmt", path =>'d:\pfe\attach.txt'; } MIME::Lite->send('smtp', "smtp.service.ohio-state.edu", Timeout=>60); $msg->send; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]