Most mentioned links:MMBase documentation
MMBase Taglib reference
The reference for all tags mm
The mmbase email application enables you to send email with for example a contactform or you can even build a mailinglist with it. You can save the mails after they have been send, or discard them.
After you have installed the 'mmbase-email.jar' in your webapp's '/WEB-INF/lib/' directory, you need to configure Apache Tomcat or another prefered webapplication server. Following the configuration instructions in the README with the application this basically boils down to enabling a mail Resource for your webapplication's context. For example:
<Context path="" docBase="ROOT" debug="0">
<!-- there is normally more stuff here about your webapp -->
<Resource name="mail/Session" auth="Container"
mail.smtp.host="smtp.someplace.org" /> </Context>
After that sending mail is quite easy.
<%-- pagelogin to enable visitors to create email nodes --%>The 'type' function parameter is 'oneshotkeep' which sends email and stores it as an email node in mmbase. If you don't want to start collecting email from your site you can use the nodefunction with the parameter 'type' at 'oneshot'.
<mm:cloud username="foo" password="bar" method="pagelogon">
<%-- create an email node --%>
<mm:createnode id="new_email_node" type="email">
<mm:setfield name="subject">Just saying hi</mm:setfield>
<mm:setfield name="body">Hi there! How are you.</mm:setfield>
<%-- the function 'mail' shoots it off into the world --%>
<mm:function name="mail" />
<%-- let the visitor know what happened with it --%>
<h2>Thanks. Your mail has been send.</h4>
<h2>Some error occured!</h4>
<mm:function name="mail" />
That's it. Other features of the email application include sending multipart email like mail with attachments or html.
6 comments | leave a comment ↓
Really like the tips and the description you give with them.
I am using the stuff you described above.
But after a test I get "Operation 'write' on 1395810 was NOT permitted to anonymous".
Why does this happen? Is this because the email node is stored by anonymous? I don't really understand what you do in the uppermost part. In which you add some stuff to the Tomcat Configuration.
Can you help me with this. Or is it just a case of adding more rights to anonymous?
You could give anonymous more rights, but it would perhaps be safer to only give the page more rights.
So, don't use <mm:cloud>
<mm:cloud method="delegate" authenticate="class">
I think a default configuration would provide an administrator cloud then. Otherwise it can be configured in config/security/classauthentication.xml.
Thanks a lot. Easiest for me is to just to use the pagelogon attribute on the <mm:cloud /> tag. Like:
<mm:cloud username="foo" password="bar" method="pagelogon"> ... </mm:cloud>
User 'foo' (or another basic user) is in a default mmbase setup normally allowed to create nodes in the body of the cloud tag in this example.
And Tomcat needs to know where to deliver mail. You would probably also need the JavaMail API. More information is in on Tomcat's website:
"And Tomcat needs to know where to deliver mail. You would probably also need the JavaMail API. More information is in on Tomcat's website:
Couldn't you use sendmail.xml to set the mail properties? I have no access to Tomcat installation?
Nice to see your reactions......:-)
Thanks again and I believe you're right. You probably can still use the configuration of the email application in 'config/modules/sendmail.xml' in stead of JNDI Resources, but I haven't used it in a while. See the commented parts in http://scm.mmbase.org/view/mmbase/trunk/applications/email/src/main/config/modules/sendmail.xml?view=markup
I modified the sendmail.xml (WEB-INF\config\modules\)
looks a bit like this :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//MMBase//DTD module config 1.0//EN" "http://www.mmbase.org/dtd/module_1_0.dtd">
<module maintainer="mmbase.org" version="0">
Then in the jsp I used "<mm:cloud username="foo" password="bar" method="pagelogon">" and after that it worked like a breeze .
I will keep visiting your site. I found it trough Twitter, although I think Twitter is overrated :-)