|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.restlet.util.Helper<T>
com.noelios.restlet.ConnectorHelper<Client>
com.noelios.restlet.ClientHelper
com.noelios.restlet.ext.javamail.JavaMailClientHelper
public class JavaMailClientHelper
Client connector to a mail server. This connector supports the SMTP, SMTP
with STARTTLS and SMTPS protocols to send emails, POP v3 and POPS v3 to
retrieved emails from a mail box.
To send an email, send a POST request with a resource reference on a SMTP or
SMTPS URI and use an XML email as the entity. A SMTP URI has the following
syntax: smtp://host[:port]
Use the
Request.setChallengeResponse(org.restlet.data.ChallengeResponse)
method to set the identified/login and secret/password. You will also need to
specify the ChallengeScheme.SMTP_PLAIN challenge scheme.
Sample XML email:
<?xml version="1.0" encoding="ISO-8859-1" ?> <email> <head> <subject>Account activation</subject> <from>support@restlet.org</from> <to>user@domain.com</to> <cc>log@restlet.org</cc> </head> <body><![CDATA[Your account was sucessfully created!]]></body> </email>To receive the list of emails, send a GET request to a resource reference on a POP or POPS URI, leaving the reference path empty. A POP URI has the following syntax: pop://host[:port]
Request.setChallengeResponse(org.restlet.data.ChallengeResponse)
method to set the identified/login and secret/password. You will also need to
specify the ChallengeScheme.POP_BASIC or the
ChallengeScheme.POP_DIGEST challenge scheme.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<emails>
<email href="/1234"/>
<email href="/5678"/>
<email href="/9012"/>
<email href="/3456"/>
</emails>
To retrieve an individual email, just add the href attribute at the end of
the POP URI, such as: pop://host/1234| Parameter name | Value type | Default value | Description |
|---|---|---|---|
| startTls | boolean | false | If true, the SMTP connector will attempt to start a TLS tunnel, right after the SMTP connection is established. |
| debug | boolean | false | If true, the connector will generate JavaMail debug messages. |
| representationMessageClass | String | null | If not null, represents the name of a class that extends the JavaMail
"javax.mail.Message" class. This class is able to generate a Message from an
XML representation and a JavaMail Session. The constructor must accept a
Representation and a JavaMail Session objects as parameters in this
order. |
| Field Summary | |
|---|---|
static Protocol |
POP
POP protocol. |
static ChallengeScheme |
POP_BASIC
Basic POP scheme. |
static ChallengeScheme |
POP_DIGEST
Digest POP scheme. |
static Protocol |
POPS
POPS protocol (via SSL/TLS socket).. |
| Constructor Summary | |
|---|---|
JavaMailClientHelper(Client client)
Constructor. |
|
| Method Summary | |
|---|---|
static Request |
create(String smtpURI,
Representation email)
Deprecated. With no replacement as it creates an unecessary dependency on NRE classes. |
static Request |
create(String smtpURI,
Representation email,
String login,
String password)
Deprecated. With no replacement as it creates an unecessary dependency on NRE classes. |
protected Message |
createMessage(Representation xmlMessage,
Session session)
Creates a JavaMail message by parsing an XML representation. |
protected Representation |
createRepresentation(Message message)
Creates an XML representation based on a JavaMail message. |
protected Representation |
createRepresentation(Message[] messages,
POP3Folder inbox)
Creates an XML representation based on a list of JavaMail messages. |
String |
getRepresentationMessageClass()
Returns the full name of the class used for generating JavaMail Message instances from an XML representation and a JavaMail Session. |
void |
handle(Request request,
Response response)
|
boolean |
isDebug()
Indicates if the connector should generate JavaMail debug messages. |
boolean |
isStartTls()
Indicates if the SMTP protocol should attempt to start a TLS tunnel. |
| Methods inherited from class com.noelios.restlet.ClientHelper |
|---|
getConnectTimeout, setConnectTimeout |
| Methods inherited from class com.noelios.restlet.ConnectorHelper |
|---|
getProtocols, start, stop, update |
| Methods inherited from class org.restlet.util.Helper |
|---|
getAttributes, getContext, getHelped, getHelpedParameters, getLogger, setHelped |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Protocol POP
public static final ChallengeScheme POP_BASIC
public static final ChallengeScheme POP_DIGEST
public static final Protocol POPS
| Constructor Detail |
|---|
public JavaMailClientHelper(Client client)
client - The client to help.| Method Detail |
|---|
@Deprecated
public static Request create(String smtpURI,
Representation email)
smtpURI - The SMTP server's URI (ex: smtp://localhost).email - The email to send (valid XML email).
@Deprecated
public static Request create(String smtpURI,
Representation email,
String login,
String password)
smtpURI - The SMTP server's URI (ex: smtp://localhost).email - The email to send (valid XML email).login - Authenticate using this login name.password - Authenticate using this password.
protected Message createMessage(Representation xmlMessage,
Session session)
throws IOException,
AddressException,
MessagingException
xmlMessage - The XML message to parse.session - The current JavaMail session.
IOException
AddressException
MessagingException
protected Representation createRepresentation(Message message)
throws DOMException,
IOException,
MessagingException
message - The JavaMail message to format.
DOMException
IOException
MessagingException
protected Representation createRepresentation(Message[] messages,
POP3Folder inbox)
throws IOException,
MessagingException
messages - The list of JavaMail messages to format.
IOException
MessagingExceptionpublic String getRepresentationMessageClass()
public void handle(Request request,
Response response)
handle in class Helper<Client>public boolean isDebug()
public boolean isStartTls()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||