Forum OpenACS Q&A: Sending mail with forms

Collapse
Posted by Gonzalo López on
I need to create a simple page inside my OpenACS installation with a form to get information from the user.

The form I've created works correctly.

In the "example.tcl" page...:

ad_page_contract {
This page allows the users to add new items to their to do list or edit existing items.
} {
item_id:optional
}

ad_form -name form -export { user_id } -form {
item_id:key
{from:text {label "From"} }
{to:text {label "To"}}
{subject:text {label "Subject"}}
{body:text {label "Body"}}
} -on_submit {
    ns_sendmail to from subject body
}

I have configured the MailHost parameter with the smtp server I have.
The error I get is the following:

Expected a 250 status line; got:
504 5.5.2 <to>: Recipient address rejected: need fully-qualified address
    while executing
"_ns_sendmail $smtp $smtpport $timeout $tolist $bcclist  $from $subject $body $extraheaders"
    (procedure "ns_sendmail" line 47)
    invoked from within
"ns_sendmail to from subject body"
    ("uplevel" body line 2)
    invoked from within
"uplevel #$level $on_submit"
    ("1" arm line 620)
    invoked from within

Thanks

Collapse
Posted by Gonzalo López on
Finally it was my fault. I was getting the information from the form in a wrong way.

Is it possible to use the ns_sendmail procedure to send mail to my gmail account using the form??

Thanks again

Collapse
Posted by Emmanuelle Raffenne on
Hi Gonzalo,

Yes it is possible. However I would recommend that you use acs_mail_lite::send rather than the ns_sendmail one.

Collapse
Posted by Ryan Gallimore on
Hi Gonzalo,

You can also validate the e-mail fields using the email datatype:

{from:email(text) ....}
{to:email(text) ....}

See the ad_form Quick Reference

Ryan