Qore jni Module 2.4.0
Loading...
Searching...
No Matches
org.qore.lang.smtpclient.SmtpClient Class Reference

Java wrapper for the Qore::SmtpClient class in Qore. More...

Inheritance diagram for org.qore.lang.smtpclient.SmtpClient:
org.qore.jni.QoreObjectWrapper

Public Member Methods

 SmtpClient (QoreObject ds)
 creates the object
 SmtpClient (String host, int port) throws Throwable
 creates the SmtpClient object
 SmtpClient (String url) throws Throwable
 creates the SmtpClient object
String getTarget () throws Throwable
 Returns the connection target string.
void tls (boolean n_tls) throws Throwable
 sets the TLS/SSL flag
boolean tls () throws Throwable
 returns the TLS/SSL flag
void ssl (boolean n_ssl) throws Throwable
 sets the SSL connection flag
boolean ssl () throws Throwable
 returns the SSL connection flag
void setUserPass (String n_user, String n_pass) throws Throwable
 sets the username and password for authenticated connections
void test (boolean ns) throws Throwable
 sets or disables test mode; no connections are made in test mode
boolean test () throws Throwable
 returns the test mode flag
void connect () throws Throwable
 Connect to the server with the connection parameters set in the constructor().
boolean isConnected () throws Throwable
 return connection status
void disconnect () throws Throwable
 disconnect from the server
void setReadTimeout (int to) throws Throwable
 sets the read timeout from an integer in milliseconds
void setReadTimeout (QoreRelativeTime to) throws Throwable
 sets the read timeout
int getReadTimeoutMs () throws Throwable
 returns the read timeout as an integer giving milliseconds
QoreRelativeTime getReadTimeoutDate () throws Throwable
 returns the read timeout as a relative time value
void setConnectTimeout (int to) throws Throwable
 sets the connect timeout from an integer in milliseconds
void setConnectTimeout (QoreRelativeTime to) throws Throwable
 sets the connect timeout
int getConnectTimeoutMs () throws Throwable
 returns the connect timeout as an integer giving milliseconds
QoreRelativeTime getConnectTimeoutDate () throws Throwable
 returns the connect timeout as a relative time value
HashMap< String, HashMap< String, Object > > sendMessage (Message message) throws Throwable
 send a Message to the server
void forceDisconnect () throws Throwable
 force disconnect of socket without error
HashMap< String, Object > getUsageInfo () throws Throwable
 Returns performance statistics for the socket.
void clearStats () throws Throwable
 Clears performance statistics.
Public Member Methods inherited from org.qore.jni.QoreObjectWrapper
 QoreObjectWrapper (QoreObject obj)
 creates the wrapper object with the Qore object
void release ()
 releases the Qore object; do not call any further methods on the object after this call
QoreObject getQoreObject ()
 returns the Qore object
String className ()
 returns the class name for the Qore object
boolean instanceOf (String class_name)
 returns true if the object is an instance of the given class

Additional Inherited Members

Private Attributes inherited from org.qore.jni.QoreObjectWrapper
QoreObject obj
 the wrapper Qore object

Detailed Description

Java wrapper for the Qore::SmtpClient class in Qore.

Note
Loads and initializes the Qore library and the jni module in static initialization if necessary
Deprecated
Use dynamic imports instead: import qoremod.SmtpClient.SmtpClient;

Constructor & Destructor Documentation

◆ SmtpClient() [1/2]

org.qore.lang.smtpclient.SmtpClient.SmtpClient ( String host,
int port ) throws Throwable
inline

creates the SmtpClient object

Parameters
hostthe hostname of the SMTP server (use "[hostname]" to explicitly specify an ipv6 connection)
portthe port number of the SMTP server

◆ SmtpClient() [2/2]

org.qore.lang.smtpclient.SmtpClient.SmtpClient ( String url) throws Throwable
inline

creates the SmtpClient object

Example:
SmtpClient smtp("smtptls://user@gmail.com:password@smtp.gmail.com", \log(), \log());
Parameters
urlthe URL of the SMTP server (use "[hostname]" or "[address]" for ipv6 connections); if no protocol (scheme) and no port is given for non-UNIX sockets, then SmtpPort is used as the default port number. This argument is parsed with parse_url(); see smtpclient_protocols for a description of the handling of the protocol (scheme) component of the URL including default ports per protocol (scheme). If an unknown protocol (scheme) is given then a SMTP-UNKNOWN-PROTOCOL exception is raised
Exceptions
PARSE-URL-ERRORthe url argument could not be parsed with parse_url()
SMTPCLIENT-UNKNOWN-PROTOCOLthe protocol (scheme) given is unknown or unsupported
SMTPCLIENT-INVALID-AUTHENTICATIONpartial authentication credentials passed; the username or password is missing

Member Function Documentation

◆ clearStats()

void org.qore.lang.smtpclient.SmtpClient.clearStats ( ) throws Throwable
inline

Clears performance statistics.

Example:
smtp.clearStats();
Since
SmtpClient 1.3
See also
getUsageInfo()

◆ connect()

void org.qore.lang.smtpclient.SmtpClient.connect ( ) throws Throwable
inline

Connect to the server with the connection parameters set in the constructor().

Note
  • For possible exceptions, see Qore's Socket::connect() method
  • This method is subject to thread serialization

◆ disconnect()

void org.qore.lang.smtpclient.SmtpClient.disconnect ( ) throws Throwable
inline

disconnect from the server

Note
This method is subject to thread serialization

◆ forceDisconnect()

void org.qore.lang.smtpclient.SmtpClient.forceDisconnect ( ) throws Throwable
inline

force disconnect of socket without error

Note
This method is subject to thread serialization

◆ getTarget()

String org.qore.lang.smtpclient.SmtpClient.getTarget ( ) throws Throwable
inline

Returns the connection target string.

Since
SmtpClient 1.7

◆ getUsageInfo()

HashMap< String, Object > org.qore.lang.smtpclient.SmtpClient.getUsageInfo ( ) throws Throwable
inline

Returns performance statistics for the socket.

Example:
HashMap<String, Object> h = smtp.getUsageInfo();
Returns
a hash with the following keys:
  • "bytes_sent": an integer giving the total amount of bytes sent
  • "bytes_recv": an integer giving the total amount of bytes received
  • "us_sent": an integer giving the total number of microseconds spent sending data
  • "us_recv": an integer giving the total number of microseconds spent receiving data
  • "arg": the optional argument for warning hashes if applicable
  • "timeout": the warning timeout in microseconds if set
  • "min_throughput": the minimum warning throughput in bytes/sec if set
Since
SmtpClient 1.3
See also
clearStats()

◆ sendMessage()

HashMap< String, HashMap< String, Object > > org.qore.lang.smtpclient.SmtpClient.sendMessage ( Message message) throws Throwable
inline

send a Message to the server

Parameters
messagethe Message to send
Returns
a hash of data returned by the SMTP server (the return structure hashes described below are made up of the following keys: "code": the return code, "desc": the string description):
  • HELO or EHLO: a hash of the reply received from the HELO or EHLO command
  • RCPT: hash keyed by email address with hash return structures values for the RCPT TO command
  • MSGID: return structure after the send; generally contains message id
  • QUIT: the server response of the disconnect command
Note
This method is subject to thread serialization
Exceptions
MESSAGE-ERRORthe message is incomplete and cannot be sent

◆ setUserPass()

void org.qore.lang.smtpclient.SmtpClient.setUserPass ( String n_user,
String n_pass ) throws Throwable
inline

sets the username and password for authenticated connections

Parameters
n_userthe username to set for authentication
n_passthe password to set for authentication
Note
  • Currently this class only knows how to do AUTH PLAIN authentication
  • This method is subject to thread serialization

◆ ssl()

void org.qore.lang.smtpclient.SmtpClient.ssl ( boolean n_ssl) throws Throwable
inline

sets the SSL connection flag

Parameters
n_sslif True then connections to the SMTP server will immediately try to negotiate transport layer TSL/SSL security; will also in this case turn off the TLS/SSL "STARTTLS" application layer security flag

◆ tls()

void org.qore.lang.smtpclient.SmtpClient.tls ( boolean n_tls) throws Throwable
inline

sets the TLS/SSL flag

Parameters
n_tlsif True then use TLS/SSL; if the TLS/SSL flag is set then the client will issue a "STARTTLS" command after connecting and negotiate a secure TLS/SSL connection to the server; will also in this case turn off the SSL connection flag

The documentation for this class was generated from the following file:
  • src/java/org/qore/lang/smtpclient/SmtpClient.java