Package org.restlet.ext.javamail
Class JavaMailClientHelper
- java.lang.Object
-
- org.restlet.engine.Helper
-
- org.restlet.engine.RestletHelper<T>
-
- org.restlet.engine.connector.ConnectorHelper<Client>
-
- org.restlet.engine.connector.ClientHelper
-
- org.restlet.ext.javamail.JavaMailClientHelper
-
@Deprecated public class JavaMailClientHelper extends ClientHelper
Deprecated.Will be removed in next major release.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 theRequest.setChallengeResponse(org.restlet.data.ChallengeResponse)method to set the identified/login and secret/password. You will also need to specify theChallengeScheme.SMTP_PLAINchallenge 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 successfully 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]
Use theRequest.setChallengeResponse(org.restlet.data.ChallengeResponse)method to set the identified/login and secret/password. You will also need to specify theChallengeScheme.POP_BASICor theChallengeScheme.POP_DIGESTchallenge scheme.
Sample XML list of emails:
<?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
Here is the list of parameters that are supported. They should be set in the Client's context before it is started: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 Representationand a JavaMail Session objects as parameters in this order.
-
-
Constructor Summary
Constructors Constructor Description JavaMailClientHelper(Client client)Deprecated.Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected javax.mail.MessagecreateMessage(Representation xmlMessage, javax.mail.Session session)Deprecated.Creates a JavaMail message by parsing an XML representation.protected RepresentationcreateRepresentation(javax.mail.Message message)Deprecated.Creates an XML representation based on a JavaMail message.protected RepresentationcreateRepresentation(javax.mail.Message[] messages, com.sun.mail.pop3.POP3Folder inbox)Deprecated.Creates an XML representation based on a list of JavaMail messages.private java.lang.StringgetLogin(Request request)Deprecated.Returns the request login.private java.lang.StringgetPassword(Request request)Deprecated.Returns the request password.java.lang.StringgetRepresentationMessageClass()Deprecated.Returns the full name of the class used for generating JavaMail Message instances from an XML representation and a JavaMail Session.voidhandle(Request request, Response response)Deprecated.Handles a call.private voidhandlePop(Request request, Response response)Deprecated.Handles a POP or POPS request.private voidhandleSmtp(Request request, Response response)Deprecated.Handles a SMTP or SMTPS request.booleanisDebug()Deprecated.Indicates if the connector should generate JavaMail debug messages.booleanisStartTls()Deprecated.Indicates if the SMTP protocol should attempt to start a TLS tunnel.-
Methods inherited from class org.restlet.engine.connector.ConnectorHelper
getConnectorService, getContext, getProtocols, start, stop, update
-
Methods inherited from class org.restlet.engine.RestletHelper
getAttributes, getHelped, getHelpedParameters, getLogger, getMetadataService, setHelped
-
-
-
-
Constructor Detail
-
JavaMailClientHelper
public JavaMailClientHelper(Client client)
Deprecated.Constructor.- Parameters:
client- The client to help.
-
-
Method Detail
-
createMessage
protected javax.mail.Message createMessage(Representation xmlMessage, javax.mail.Session session) throws java.io.IOException, javax.mail.internet.AddressException, javax.mail.MessagingException
Deprecated.Creates a JavaMail message by parsing an XML representation.- Parameters:
xmlMessage- The XML message to parse.session- The current JavaMail session.- Returns:
- The created JavaMail message.
- Throws:
java.io.IOExceptionjavax.mail.internet.AddressExceptionjavax.mail.MessagingException
-
createRepresentation
protected Representation createRepresentation(javax.mail.Message message) throws org.w3c.dom.DOMException, java.io.IOException, javax.mail.MessagingException
Deprecated.Creates an XML representation based on a JavaMail message.- Parameters:
message- The JavaMail message to format.- Returns:
- The XML representation.
- Throws:
org.w3c.dom.DOMExceptionjava.io.IOExceptionjavax.mail.MessagingException
-
createRepresentation
protected Representation createRepresentation(javax.mail.Message[] messages, com.sun.mail.pop3.POP3Folder inbox) throws java.io.IOException, javax.mail.MessagingException
Deprecated.Creates an XML representation based on a list of JavaMail messages.- Parameters:
messages- The list of JavaMail messages to format.- Returns:
- The XML representation.
- Throws:
java.io.IOExceptionjavax.mail.MessagingException
-
getLogin
private java.lang.String getLogin(Request request)
Deprecated.Returns the request login.- Parameters:
request- The high-level request.- Returns:
- The login.
-
getPassword
private java.lang.String getPassword(Request request)
Deprecated.Returns the request password.- Parameters:
request- The high-level request.- Returns:
- The password.
-
getRepresentationMessageClass
public java.lang.String getRepresentationMessageClass()
Deprecated.Returns the full name of the class used for generating JavaMail Message instances from an XML representation and a JavaMail Session.- Returns:
- The full name of the class used for generating JavaMail Message instances from an XML representation and a JavaMail Session.
-
handle
public void handle(Request request, Response response)
Deprecated.Description copied from class:RestletHelperHandles a call.- Overrides:
handlein classRestletHelper<Client>- Parameters:
request- The request to handle.response- The response to update.
-
handlePop
private void handlePop(Request request, Response response) throws javax.mail.MessagingException, java.io.IOException
Deprecated.Handles a POP or POPS request.- Parameters:
request- The request to handle.response- The response to update.- Throws:
java.io.IOExceptionjavax.mail.MessagingExceptionjava.io.IOException
-
handleSmtp
private void handleSmtp(Request request, Response response) throws java.io.IOException, javax.mail.MessagingException
Deprecated.Handles a SMTP or SMTPS request.- Parameters:
request- The request to handle.response- The response to update.- Throws:
java.io.IOExceptionjavax.mail.MessagingException
-
isDebug
public boolean isDebug()
Deprecated.Indicates if the connector should generate JavaMail debug messages.- Returns:
- True the connector should generate JavaMail debug messages.
-
isStartTls
public boolean isStartTls()
Deprecated.Indicates if the SMTP protocol should attempt to start a TLS tunnel.- Returns:
- True if the SMTP protocol should attempt to start a TLS tunnel.
-
-