Package org.quartz.jobs.ee.mail
Class SendMailJob
- java.lang.Object
-
- org.quartz.jobs.ee.mail.SendMailJob
-
- All Implemented Interfaces:
org.quartz.Job
public class SendMailJob extends java.lang.Object implements org.quartz.JobA Job which sends an e-mail with the configured content to the configured recipient. Arbitrary mail.smtp.xxx settings can be added to job data and they will be passed along the mail session
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classSendMailJob.MailInfo
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPROP_CC_RECIPIENTThe e-mail address to cc the mail to.static java.lang.StringPROP_CONTENT_TYPEThe message content type.static java.lang.StringPROP_MESSAGEThe e-mail message body.static java.lang.StringPROP_PASSWORDPassword for authenticated session.static java.lang.StringPROP_RECIPIENTThe e-mail address to send the mail to.static java.lang.StringPROP_REPLY_TOThe e-mail address the message should say to reply to.static java.lang.StringPROP_SENDERThe e-mail address to claim the mail is from.static java.lang.StringPROP_SMTP_HOSTThe host name of the smtp server.static java.lang.StringPROP_SUBJECTThe subject to place on the e-mail.static java.lang.StringPROP_USERNAMEUsername for authenticated session.
-
Constructor Summary
Constructors Constructor Description SendMailJob()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SendMailJob.MailInfocreateMailInfo()voidexecute(org.quartz.JobExecutionContext context)protected org.slf4j.LoggergetLog()protected jakarta.mail.SessiongetMailSession(SendMailJob.MailInfo mailInfo)protected java.lang.StringgetOptionalParm(org.quartz.JobDataMap data, java.lang.String property)protected java.lang.StringgetRequiredParm(org.quartz.JobDataMap data, java.lang.String property, java.lang.String constantName)protected SendMailJob.MailInfopopulateMailInfo(org.quartz.JobDataMap data, SendMailJob.MailInfo mailInfo)protected jakarta.mail.internet.MimeMessageprepareMimeMessage(SendMailJob.MailInfo mailInfo)protected voidsetMimeMessageContent(jakarta.mail.internet.MimeMessage mimeMessage, SendMailJob.MailInfo mailInfo)
-
-
-
Field Detail
-
PROP_SMTP_HOST
public static final java.lang.String PROP_SMTP_HOST
The host name of the smtp server. REQUIRED.- See Also:
- Constant Field Values
-
PROP_RECIPIENT
public static final java.lang.String PROP_RECIPIENT
The e-mail address to send the mail to. REQUIRED.- See Also:
- Constant Field Values
-
PROP_CC_RECIPIENT
public static final java.lang.String PROP_CC_RECIPIENT
The e-mail address to cc the mail to. Optional.- See Also:
- Constant Field Values
-
PROP_SENDER
public static final java.lang.String PROP_SENDER
The e-mail address to claim the mail is from. REQUIRED.- See Also:
- Constant Field Values
-
PROP_REPLY_TO
public static final java.lang.String PROP_REPLY_TO
The e-mail address the message should say to reply to. Optional.- See Also:
- Constant Field Values
-
PROP_SUBJECT
public static final java.lang.String PROP_SUBJECT
The subject to place on the e-mail. REQUIRED.- See Also:
- Constant Field Values
-
PROP_MESSAGE
public static final java.lang.String PROP_MESSAGE
The e-mail message body. REQUIRED.- See Also:
- Constant Field Values
-
PROP_CONTENT_TYPE
public static final java.lang.String PROP_CONTENT_TYPE
The message content type. For example, "text/html". Optional.- See Also:
- Constant Field Values
-
PROP_USERNAME
public static final java.lang.String PROP_USERNAME
Username for authenticated session. Password must also be set if username is used. Optional.- See Also:
- Constant Field Values
-
PROP_PASSWORD
public static final java.lang.String PROP_PASSWORD
Password for authenticated session. Optional.- See Also:
- Constant Field Values
-
-
Method Detail
-
execute
public void execute(org.quartz.JobExecutionContext context) throws org.quartz.JobExecutionException- Specified by:
executein interfaceorg.quartz.Job- Throws:
org.quartz.JobExecutionException- See Also:
Job.execute(org.quartz.JobExecutionContext)
-
getLog
protected org.slf4j.Logger getLog()
-
prepareMimeMessage
protected jakarta.mail.internet.MimeMessage prepareMimeMessage(SendMailJob.MailInfo mailInfo) throws jakarta.mail.MessagingException
- Throws:
jakarta.mail.MessagingException
-
setMimeMessageContent
protected void setMimeMessageContent(jakarta.mail.internet.MimeMessage mimeMessage, SendMailJob.MailInfo mailInfo) throws jakarta.mail.MessagingException- Throws:
jakarta.mail.MessagingException
-
getMailSession
protected jakarta.mail.Session getMailSession(SendMailJob.MailInfo mailInfo) throws jakarta.mail.MessagingException
- Throws:
jakarta.mail.MessagingException
-
createMailInfo
protected SendMailJob.MailInfo createMailInfo()
-
populateMailInfo
protected SendMailJob.MailInfo populateMailInfo(org.quartz.JobDataMap data, SendMailJob.MailInfo mailInfo)
-
getRequiredParm
protected java.lang.String getRequiredParm(org.quartz.JobDataMap data, java.lang.String property, java.lang.String constantName)
-
getOptionalParm
protected java.lang.String getOptionalParm(org.quartz.JobDataMap data, java.lang.String property)
-
-