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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adobe fdf file and sendmail 2

Status
Not open for further replies.

random260

Programmer
Mar 11, 2002
116
US
I have some Adobe forms that I created and posted online - users fill them out, then they are sent to me as fdf files through an adobe email link. Now however, I would like them sent to me via sendmail so that can collect some additional information before, but I am running into some issues I'm not sure how to deal with.

1) Adobe has the ability to submit to a URL (for the cgi script) but what the heck is it submitting? I KNOW I can parse the fields individually from the form, but what I WANT is to just send it as an attachment. Currently when the user clicks the send button in adobe it opens their email client and attaches an fdf file - how do I tell either Adobe to submit the info as a FILE to my cgi script, or tell my cgi script to receive it as a file instead of parsing individual fields?

And once I get an answer to that.....

2) I have a sendmail script that I wrote that works just ducky, BUT - there MUST be an easy way to attach a file to a email sent by sendmail isn't there? Preferable without having to install MIME lite or something that I have no experience with? I believe I asked this particular question once before but gave up on the answer when i couldn't understand it without a lot of work lol.

Thanks in advance people.
 
random260,

first, Why not just change your pdf to a(n) html form, and have that call the cgi script where you're in complete control.

second, if you don't install modules and play, you'll never have experince - they're well written, usually well documented.

my €0.02c
--Paul
 
This might answer one part of your question, here is the code I use to send attachments via sendmail, it works very well:
Code:
use MIME::QuotedPrint;
use MIME::Base64;
use Mail::Sendmail 0.75; # doesn't work with v. 0.74!

%mail = (
         from => 'you@domain.tld',
         to => 'whoever@someplace.tld',
         subject => 'Test attachment',
        );


$boundary = "====" . time() . "====";
$mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";

$message = encode_qp( "Here is a fdf attachment!" );

$file = '/your/file/here.fdf'; # This is the attachment

open (F, $file) or die "Cannot read $file: $!";
binmode F; undef $/;
$mail{body} = encode_base64(<F>);
close F;

$boundary = '--'.$boundary;
$mail{body} = <<END_OF_BODY;
$boundary
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

$message
$boundary
Content-Type: application/octet-stream; name="$^X"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="$^X"

$mail{body}
$boundary--
END_OF_BODY

sendmail(%mail) || print "Error: $Mail::Sendmail::error\n";

It looks pretty hectic, but it isn't. All you have to change is the 'to', 'from', 'message' and 'file' variables to suite your needs.

If you want to send multiple attachments it gets slightly trickier.

The Mail::Sender module is alot simpler, but I have never gotten it to work, here is how that module send attachments:
Code:
use Mail::Sender;

$sender = new Mail::Sender
{smtp => 'mail.yourdomain.com', from => 'your@address.com'};
$sender->MailFile({to => 'some@address.com',
                   subject => 'Here is the file',
                   msg => "I'm sending you the list you wanted.",
                   file => 'filename.txt'});
Hope it helps.

Sean.
 
Paul;

Well, as far as making the form an HTML instead of fdf, I would love to, but that won't work - over 200 forms and rising, all created in ^&%!&^%&@#!!! Adobe (I didn't create them). The data needs to go directly back into Adobe when it gets to where it is going. And of course they were not created with any standard convention - on one form "name" is entered into txtName text box, on the next one it's entered into text11, etc. As to installing modules, maybe you can answer a question or two for me about it, as I have never done it (and would love to because I agree - playing is the only way) - is MIME::lite something I would have to convince my ISP to install, or is this something that I can just drop into my cgi folder? I couldn't seem to find a clear answer on that (not even from my ISP). I have quite a few nice examples using MIME::lite that I understand what is going on and could use to write my own code, but no good unless I can install it. When I did a Google search for MIME::lite I got so many hits that I have not (yet - only started yesterday and only had a couple of minutes) been able to track down where to download it an get some documentation on it.

Sean;

Thanks for the code examples - your right, pretty straight forward. I would like to see if I CAN install and use the MIME::lite (simply because I like to play around with new toys), but if I can't this is great.

Steve

 
random260 -->
You do not need your isp to install the module for you, although I am sure they can. Installing a module is an extremely easy business. Here is an example of how we install a module on our servers:

We simply type this line in a linux terminal:
perl -MCPAN -e "install MIME::lite"

And voila! The install starts. Doesn't take longer than a minute usually.

You can however do it yourself, without the aid of your isp, take a look at this link for a description on how to do it:

Hope it helps.

Sean.
 
Jeese... could it be any easier? lol. Thanks Sean.
 
random260

Can I get a copy of your CGI file or post it here?
I have been looking for something like that for some time and I guess I finally found someone that has an answer to it.
 
Which part of the script do you want - the part that sends the email with a file attached, or just the simple sendmail routine (with or without information harvested from a web page)? I'm still working on it (been short on time) but if you let me know exactly what you want I will either post it here or email it to you. if it is a part I have finished already I'll send it now - otherwise I'll try to hurry it along so i can send you the finished product.

Steve
 
I using Windows So sendmail wont work but I'm alreadu looking into other options like mail::sender and SMTP all seem to work for what I need but if you can show me how use a script to get the FDF file from the form and simply attach it to an email that I choose it will be almost 75% done.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top