Package com.jbstrap.core.mail
Class EmailAPI
java.lang.Object
com.jbstrap.core.mail.EmailAPI
Email sender implementer API class. For email sending, an
Email
instance is necessary, which will be sent. The email server's can be given parameters in the
Email
instance, or can be stored in messages, that will have to be loaded by the application, by using the MessageSourceAPI
.- Since:
- 4.0
- Author:
- JBStrap
- See Also:
-
Method Details
-
prepareEmail
Creates a new emptyEmail
object- Returns:
- The created email object
- See Also:
-
prepareEmail
Creates a newEmail
object. If setFromResource parameter is true, then the mail object parameters made frommessages
. These parameters can be overwritten, in the createdEmail
object.
The parameter keys read from theMessageSourceAPI
:
host: mail.smtp.host
port: mail.smtp.port
socketFactoryPort: mail.smtp.socketFactory.port
socketFactoryClass: mail.smtp.socketFactory.class
starttlsEnable: mail.smtp.starttls.enable
transportProtocol: mail.transport.protocol
sslEnable: mail.smtp.ssl.enable
sslTrust: mail.smtp.ssl.trust
auth: mail.smtp.auth
userName: mail.smtp.username
password: mail.smtp.password
debugEnabled: mail.debug.enabled- Parameters:
setFromResource
- Set email parameters from message source or not- Returns:
- The created email object
- See Also:
-
sendMail
public static void sendMail(Email email) throws javax.mail.internet.AddressException, javax.mail.MessagingException, UnsupportedEncodingException Sends anEmail
, that is created by calling theprepareEmail
method- Parameters:
email
- The parameters needed for sending the Email, and the instance containing the email itself (host, port, auth, from, to, subject, ...).- Throws:
javax.mail.internet.AddressException
- Occurs if either address is wrong, cannot be parsed.UnsupportedEncodingException
- Occurs if the name that is to be displayed can't be set, due to a character encoding errorjavax.mail.MessagingException
- Occurs if any other error is encountered during the email sending process.
-