Forum OpenACS Q&A: sending email with attachments

Can anyone give me pointers to resources for sending emails with attachments from the ACS.

I have seen some mention of the ns_uuencode module,but I could really use a write up of someones success story or a link to the relevant spec.

Thank You,

Collapse
Posted by Roberto Mello on
I haven't done it with standard OpenACS API, but I've done it with Tcllib (which is probably what we should be doing):

http://mini.net/tcl/3016

Collapse
Posted by Titi Ala'ilima on
(Note: I'm working in MACS, so applicability to OACS may vary)

I've used tcllib as well.  i wrote a pretty nice parser for the email-handler that puts MIME messages into acs-messages (for e-mail to bboard functionality), which I can pass along if there is desire.

Is there a good way of embedding tcllib into the interpreters?  I've had to source Tcllib for every interpreter that would need it.

Collapse
Posted by Erik Rogneby on
If you are only going to be sending out one type of atachment and want a hard wired solution I used the following to generate a txt file attachment.

set set_id [ns_set new]
ns_set put $set_id "Mime-Version" "1.0"
ns_set put $set_id "Content-Type:" "text/plain; charset=\"us-ascii\""
ns_set put $set_id "Content-Disposition" "attachment; filename=\"$filename.txt\""
ns_sendmail $to $from $subject "$email_body" $set_id

For sending binary info just encoding the body and changing the Content-Type should do the trick. (although more mime info might be needed) I've decoded incoming attachment, but not the other way around. It turns out that text file attachments can be sent as actual text. (but don't have to be)

Anyhow, the fact that ns_sendmail can accept a set of mime information is what is really useful to communicate.

Hope this helps.