forked from linagora/Greenmail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jboss-service.html
174 lines (155 loc) · 8.39 KB
/
jboss-service.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>GreenMail - JBoss Service</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css" />
</head>
<body>
<div id="header">
<img src="pics/greenmail.gif" title="GreenMail - Testing SMTP, POP3, IMAP">
Latest Release GreenMail v1.3.1b - May 27th, 2009
</div>
<div class="pages">
<span class="page"><a href="readme.html">About</a></span>
| <span class="page"><a href="examples.html">Examples</a></span>
| <span class="page"><a href="jboss-service.html">JBoss</a></span>
| <span class="page"><a href="faq.html">FAQ</a></span>
| <span class="page"><a href="javadocs/index.html">Javadocs</a></span>
| <span class="page"><a href="http://www.icegreen.com/articles">Blog</a></span>
| <span class="page"><a href="http://sourceforge.net/project/showfiles.php?group_id=159695">Download</a></span>
| <span class="page"><a href="feedback.html">Feedback</a></span>
</div>
<br>
<table width="100%">
<tr><td>
<h2>GreenMail JBoss Service</h2>
GreenMail provides a JBoss Service for easy JBoss integration. The usage szenario is a
development or test environment where a real mail server is too much overhead.
With the GreenMail mail service each developer has its own local mail server sandbox -
so there's no danger for accidentally leaking test mails into the Internet.
<ul>
<li><a href="#deploy">Deploy the service</a></li>
<li><a href="#configure">Configurable user accounts</a></li>
<li><a href="#inject_via_client">Send a mail message using your mail client</a></li>
<li><a href="#inject_via_jmx">Send a mail message via JMX</a></li>
<li><a href="#list_mail_for_user">List mails for a user via JMX</a></li>
</ul>
<h3><a name="deploy">Deploy the service</a></h3>
<ol>
<li>The first step is to download the current service which we distribute as a JBoss SAR (Service Archive).</li>
<li>Unjar the service to your server deploy directory.
<p>
This example uses the <em>default</em> server, where the service is deployed in exploded mode for
following <a href="#configure">configuration</a>.
<div class="codeSample"><pre>
> cd ${JBOSS_HOME}/server/default/deploy
> mkdir greenmail-jboss-service.sar
> cd greenmail-jboss-service
> jar xvf /path/to/greenmail-jboss-service-XXX.jar
</div>
</pre>
</p>
</li>
</ol>
Starting JBoss will now automatically also start the GreenMail JBoss Service. You can see a startup message on the console output, including basic configuration data like active protocolls and their ports:
<div class="codeSample"><pre>
...
[exec] 01:03:08,387 INFO [Server] Starting JBoss (MX MicroKernel)...
[exec] 01:03:08,388 INFO [Server] Release ID: JBoss [Zion] 4.0.5.GA (build: CVSTag=Branch_4_0 date=200610162339)
[exec] 01:03:08,394 INFO [Server] Home Dir: /Users/mm/devel/example-project/target/jboss
[exec] 01:03:08,394 INFO [Server] Home URL: file:/Users/mm/devel/example-project/target/jboss/
[exec] 01:03:08,395 INFO [Server] Patch URL: null
[exec] 01:03:08,395 INFO [Server] Server Name: example-project
[exec] 01:03:08,395 INFO [Server] Server Home Dir: /Users/mm/devel/example-project/target/jboss/server/example-project
[exec] 01:03:08,395 INFO [Server] Server Home URL: file:/Users/mm/devel/example-project/target/jboss/server/example-project/
[exec] 01:03:08,395 INFO [Server] Server Log Dir: /Users/mm/devel/example-project/target/jboss/server/example-project/log
[exec] 01:03:08,395 INFO [Server] Server Temp Dir: /Users/mm/devel/example-project/target/jboss/server/example-project/tmp
[exec] 01:03:08,396 INFO [Server] Root Deployment Filename: jboss-service.xml
[exec] 01:03:08,618 INFO [ServerInfo] Java version: 1.5.0_07,Apple Computer, Inc.
[exec] 01:03:08,618 INFO [ServerInfo] Java VM: Java HotSpot(TM) Client VM 1.5.0_07-87,"Apple Computer, Inc."
[exec] 01:03:08,618 INFO [ServerInfo] OS-System: Mac OS X 10.4.9,i386
[exec] 01:03:08,908 INFO [Server] Core system initialized
[exec] 01:03:10,136 INFO [WebService] Using RMI server codebase: http://noname:8083/
[exec] 01:03:10,153 INFO [Log4jService$URLWatchTimerTask] Configuring from URL: resource:log4j.xml
[exec] 01:03:11,572 INFO <b>[GreenMailService] Starting greenmail service ( host=127.0.0.1, smtp:3025 pop3:3110 imap:3143 )</b>
...
</pre>
</div>
Opening the JBoss Console, you can see the GreenMail Service JMX Bean:
<p><img src="pics/greenmail-jboss-console.gif" alt="JBoss Console 4.2.0 GA with GreenMail Service JMX Bean"/></p>
You find two entries, of which the second one holds our interest:
<ul>
<li>A loader for isolated class loading inside the JBoss service (as to prevent the greenmail JavaMail to conflict with the application server version).</li>
<li>The <em>GreenMail</em> service bean for managing GreenMail</li>
</ul>
<h3><a name="configure">Configuring the service</a></h3>
The GreenMail service is configured by the file META-INF/jboss-service.xml in the exploded service directory.
<div class="codeSample"><pre>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE server>
<server>
<!-- Prevent JBoss classloader issues by configuring an extra classloader -->
<loader-repository>
com.icegreen.greenmail:loader=greenmail-jboss-service
</loader-repository>
<!-- The GreenMail service configration -->
<mbean code="com.icegreen.greenmail.jboss.GreenMailService"
name="com.icegreen.greenmail:type=service,name=GreenMail">
<!-- Some mail users - format is USER:PWD@HOST -->
<attribute name="Users">
test1:pwd1@localhost
test2:pwd2@localhost
</attribute>
<!-- Port offset for services. Default is 3000, so eg SMTP will be 3000+25 = 3025 . -->
<attribute name="PortOffset">
3000
</attribute>
</mbean>
</server>
</pre>
</div>
<h3><a name="inject_via_jmx">Send a message via JMX</a></h3>
<ol>
<li>Open the JBoss JMX Console in your browser (see the <a href="#deploy">deployment picture</a>).</li>
<li>Select the JMX bean of name <em>GreenMail</em> and type <em>service</em></li>
<li>Invoke the <em>sendMail</em> operation:
<p><img src="pics/greenmail-invoke-sendmail.gif" alt="sendmail JMX bean operation"/></p>
</li>
</ol>
The mail should now be visible by <a href="#list_mail_for_user">listing the user mails</a>, if there is no automatic polling of the mail box.
<h3><a name="inject_via_client">Send a message with your mail client</a></h3>
You can use your favorite mail client if you configure it for GreenMail by setting the outgoing mail to the GreenMail SMTP port.
By default this is <em>localhost:3025</em>. Of course you can also read created mail by configuring
your mail client to use GreenMail POP3 (<em>localhost:3110</em>) or IMAP (<em>localhost:3143</em>).
You will probably have to adjust these settings for your specific configuration.
<h3><a name="list_mail_for_user">List emails for a user via JMX</a></h3>
Instead of using your favourite mail client, you can use the JMX GreenMail service for listing all current mails in of a user in the GreenMail server sandbox.
<ol>
<li>Open your browser with the JMX Console and choose the GreenMail service (see <a href="#inject_via_jmx">sending mail paragraph</a>)</li>
<li>Enter the user email for the <em>listMailsForUserHTML</em> operation</em>:
<p><img src="pics/greenmail-invoke-list-mail-for-user.gif" alt="invoke list mail for user JMX bean operation"/></p>
</li>
<li>Click the invoke button. The browser now shows all emails for the specified user:
<p><img src="pics/greenmail-bean-list-mail-for-user.gif" alt="result for list mail for user JMX bean operation"/></p>
</li>
</ol>
Note that displaying mails does not modify the user mail box.
<br/><br/>
<br/><br/>
Have fun! We welcome any <a href="feedback.html">feedback</a>.
</td>
<td class="gads">
</td>
</tr>
</table>
<br>
<br>
<br>
<div class="footer">
Copyright © 2009 <a href="http://www.icegreen.com">Icegreen Technologies</a>
<br><br>
<a href="http://sourceforge.net/donate/index.php?group_id=159695"><img src="http://images.sourceforge.net/images/project-support.jpg" width="88" height="32" border="0" alt="Support This Project" /> </a>
<a href="http://sourceforge.net"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=159695&type=1" width="88" height="31" border="0" alt="SourceForge.net Logo" /></a>
</div>
</body>
</html>