Class ZSMTPMail
- All Implemented Interfaces:
ZMail
public class ZSMTPMail extends Object implements ZMail
ZMail
for SMTP mail.
This implementation is invoked by Spiderwiz framework when [mail system]
property in the
application's configuration file includes the smtp
parameter.
SMTP mail configuration example:
[mail system]smtp;server=smtp.gmail.com;user=zvilif@spiderwiz.org;pwd=dumptrump;port=465;ssl
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ZSMTPMail.Mode
Defines SMTP security protocols. -
Constructor Summary
Constructors Constructor Description ZSMTPMail()
-
Method Summary
Modifier and Type Method Description void
configure(Map<String,String> configParams)
Configures SMTP mail using the given configuration map.protected String
getPassword()
Gets the configured password to login to the SMTP server with.protected ZSMTPMail.Mode
getSmtpMode()
Gets the configured SMTP security mode.protected String
getSmtpPort()
Gets the configured SMTP port number.protected String
getSmtpServer()
Gets the configured SMTP server.protected String
getUsername()
Gets the configured username to login to the SMTP server with.void
send(String from, String to, String cc, String subject, String body, boolean html, boolean highPriority)
Sends a message via an SMTP server.protected void
setPassword(String password)
Configures the password to login to the SMTP server with.protected void
setSmtpMode(ZSMTPMail.Mode smtpMode)
Configures SMTP security mode.protected void
setSmtpPort(String smtpPort)
Configures an SMTP port number.protected void
setSmtpServer(String smtpServer)
Configures an SMTP serverprotected void
setUsername(String username)
Configures the username to login to the SMTP server with.
-
Constructor Details
-
ZSMTPMail
public ZSMTPMail()
-
-
Method Details
-
configure
Configures SMTP mail using the given configuration map.The configuration map maps configuration parameters to values. SMTP configuration parameters are:
server=
the SMTP server to use.user=
username to login with.pwd=
password to login with.port=
server port to use.ssl
- include this keyword if SSL protocol shall be used.tls
- include this keyword if TLS protocol shall be used.Example:
server=smtp.gmail.com;user=zvilif@spiderwiz.org;pwd=dumptrump;port=465;ssl
-
send
public void send(String from, String to, String cc, String subject, String body, boolean html, boolean highPriority) throws MessagingException, UnsupportedEncodingExceptionSends a message via an SMTP server.- Specified by:
send
in interfaceZMail
- Parameters:
from
- the mail address of the sender.to
- the mail address(es) of the addressee(s). Multiple addresses shall be concatenated by a comma(,) or a semicolon(;).cc
- if not null, sends a carbon copy to the specified address(es). Multiple addresses shall be concatenated by a comma(,) or a semicolon(;).subject
- the mail subject or null if there is no subject.body
- the mail body or null if there is no body.html
- true if the message shall be sent in HTML format, false if it shall be sent as plain text.highPriority
- true if the message shall be flagged as high priority.- Throws:
MessagingException
UnsupportedEncodingException
-
getSmtpServer
Gets the configured SMTP server.- Returns:
- the configured SMTP server
-
setSmtpServer
Configures an SMTP server- Parameters:
smtpServer
- SMTP server name.
-
getSmtpPort
Gets the configured SMTP port number.- Returns:
- the configured SMTP port number
-
setSmtpPort
Configures an SMTP port number.- Parameters:
smtpPort
- SMTP port number.
-
getSmtpMode
Gets the configured SMTP security mode. -
setSmtpMode
Configures SMTP security mode. -
getUsername
Gets the configured username to login to the SMTP server with.- Returns:
- the configured username to login to the SMTP server with.
-
setUsername
Configures the username to login to the SMTP server with.- Parameters:
username
- the username to login to the SMTP server with.
-
getPassword
Gets the configured password to login to the SMTP server with.- Returns:
- the configured password to login to the SMTP server with.
-
setPassword
Configures the password to login to the SMTP server with.- Parameters:
password
- the password to login to the SMTP server with.
-