Forum OpenACS Q&A: ns_sendmail

Collapse
Posted by j c on
How would you send a html email format
using AOLSERVER ns_sendmail?

can anyone help?

Collapse
2: Re: ns_sendmail (response to 1)
Posted by Jonathan Ellis on
I'd start with trying the obvious...
Collapse
3: Re: ns_sendmail (response to 1)
Posted by Tom Jackson on

You can add extra headers to you email message:

set subject "Test message"
set body "

This is a test message using HTML

" set from "me@example.com" set to "you@example.com" set extraheaders [ns_set create] ns_set put $extraheaders "Content-type" "text/html" ns_sendmail $to $from $subject $body $extraheaders
Collapse
4: Re: ns_sendmail (response to 2)
Posted by j c on
What would be the obvious?

I tried using ns_sendmail but can only
send plain text email. How would you send
an html formatted email?

Collapse
5: Re: ns_sendmail (response to 3)
Posted by j c on
Thank's for your response!

could you explain "ns_set put" command

Collapse
6: Re: ns_sendmail (response to 1)
Posted by Tom Jackson on

An ns_set is a data structure used for a lot of things in AOLserver. It is a key/value structure that allows multiple entries per key, so you can use it for html headers and database rows, and in this case email headers.

ns_set put is used to add a new key/value pair to the set.

Collapse
7: Re: ns_sendmail (response to 6)
Posted by j c on
Thanks again!!

set extraheaders [ns_set create]
ns_set put $extraheaders "Content-type" "text/html"

worked.

Collapse
8: Re: ns_sendmail (response to 1)
Posted by Paul Doerwald on
I should add a little note that using this method is a sure way to get your email caught by SpamAssassin.  The default SpamAssassin configuration flags HTML-only emails with almost all the points needed to trigger the "spam" level.

In my experience I stay away from HTML-formatted emails using ns_sendmail for this reason.

I haven't studied the code at all, but as far as I understand, acs-mail or acs-mail-lite should be able to handle properly formatted mime-encoded email messages.

Paul.