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 classZSMTPMail.ModeDefines SMTP security protocols. -
Constructor Summary
Constructors Constructor Description ZSMTPMail() -
Method Summary
Modifier and Type Method Description voidconfigure(Map<String,String> configParams)Configures SMTP mail using the given configuration map.protected StringgetPassword()Gets the configured password to login to the SMTP server with.protected ZSMTPMail.ModegetSmtpMode()Gets the configured SMTP security mode.protected StringgetSmtpPort()Gets the configured SMTP port number.protected StringgetSmtpServer()Gets the configured SMTP server.protected StringgetUsername()Gets the configured username to login to the SMTP server with.voidsend(String from, String to, String cc, String subject, String body, boolean html, boolean highPriority)Sends a message via an SMTP server.protected voidsetPassword(String password)Configures the password to login to the SMTP server with.protected voidsetSmtpMode(ZSMTPMail.Mode smtpMode)Configures SMTP security mode.protected voidsetSmtpPort(String smtpPort)Configures an SMTP port number.protected voidsetSmtpServer(String smtpServer)Configures an SMTP serverprotected voidsetUsername(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:
sendin 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:
MessagingExceptionUnsupportedEncodingException
-
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.
-